Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
private void button1_Click(object sender, EventArgs e)
{
    int number2;
    if (int.TryParse(textBox1.Text, out number2))
    {
        textBox2.Text = ("tryparse method succeed");
    }
    else { textBox2.Text=("value entered is not numeric"); }
}
Posted

1 solution

This int.tryparse method will take the string and try to convert it to integer. If it is not able to convert, then it will return false. If it is success, it will return true and also in out parameter, it will save the converted integer value.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900