To convert the string in the label into an integer, and then add 1 to get 3, the process is as follows:
//Initialize the label value
Label 1。 text = " 1.2 ";
int IValue = 0;
//can be converted into integers normally.
if (Int32。 TryParse (label 1. Text.Trim(),out IValue))
{
++ IValue;
Label 1。 Text = IValue。 ToString();
}
//Can't be converted to integer normally and report an error.
other
{
Label 1。 Text = "The value in the label label is" +Label 1. Text+ "and cannot be converted into an integer!" ;
}
Label is displayed as the value in Label is 1.2, and cannot be converted into an integer!
Initialize the label to 2 as follows
Label 1。 Text = " 2
The label is displayed as 3.