How can I convert String to Int?

后端 未结 30 2212
情歌与酒
情歌与酒 2020-11-21 05:35

I have a TextBoxD1.Text and I want to convert it to an int to store it in a database.

How can I do this?

30条回答
  •  北荒
    北荒 (楼主)
    2020-11-21 06:36

    You can try the following. It will work:

    int x = Convert.ToInt32(TextBoxD1.Text);
    

    The string value in the variable TextBoxD1.Text will be converted into Int32 and will be stored in x.

提交回复
热议问题