How can I convert String to Int?

后端 未结 30 2221
情歌与酒
情歌与酒 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:23

    Conversion of string to int can be done for: int, Int32, Int64 and other data types reflecting integer data types in .NET

    Below example shows this conversion:

    This show (for info) data adapter element initialized to int value. The same can be done directly like,

    int xxiiqVal = Int32.Parse(strNabcd);
    

    Ex.

    string strNii = "";
    UsrDataAdapter.SelectCommand.Parameters["@Nii"].Value = Int32.Parse(strNii );
    

    Link to see this demo.

提交回复
热议问题