c# string to int

You need to parse the string, and you also need to ensure that it is truly in the format of an integer.


int parsedInt = 0;
if (int.TryParse(TextBoxD1.Text, out parsedInt))
{
   // Code for if the string was valid
}
else
{
   // Code for if the string was invalid
}

0 comments:

Post a Comment