Check string is number or not in C#

Int.TryParse() method converts string into integer and if this conversion is not possible then it will return false means your inputted string is not number

string number = "1234";
int a = 0;
bool isNumber = int.TryParse(number, out a);

if (isNumber == true)
{
            //string is valid number
}
else
{
           //Given string is not a number
}

Comments

Popular posts from this blog

Display image from byte array in ASP.NET MVC

Convert a color image to black and white image in C#

Export excel and Pdf with Kendo UI MVC c#