In WinForm I need to check if the value in the TextBox is a number or not.
In PHP there is is_numeric function. Is something similar available in .NET?
I'd use TryParse to check
string str = "123";
int i;
if (int.TryParse(str, out i))
{
// it's an int
}
you should be able to do similar with other types, such as double
is_numeric, you'll find that "0x4a", "7.9" and "+1.2e3" should also return true.int val;
bool parsed = Int32.TryParse(input_str, out val);
Gives you both if it's a valid int and the result of parsing it as int as well (in val)
is_numeric. The linked answer does not provide some of the more advanced capabilities requested.is_numeric. See stackoverflow.com/a/16303109/211627 (Even if the OP is satisfied with the linked question/answer, replicatingis_numericis still an interesting challenge)