1
Answer

Conversion??

Administrator

Administrator

22y
2k
1
How can you check that the text entered in a textbox is an int? Do you have to convert this string. Is there a function that one can use to check if the content of a string is an int??
Answers (1)
1
Administrator

Administrator

Tech Writer 2.2k 1.6m 22y
Try something like this (where tb is a TextBox control) bool isInt = False; try { int res = int.Parse(tb.Text); isInt = True; } catch (Exception ex) { // error because tb.Text is not parsable to an int } if (isInt) { ... } else { ... }