Wednesday, April 8, 2009

IsNumeric in C#

In C#.NET we don’t have IsNumeric function; to achieve same functionality as IsNumeric in C# we can make use of Double.TryParse. Please find following example how we can achieve this

double db;
string strInput = "SomeValue";
if (double.TryParse(strInput, out db))
{
Response.Write(db.ToString());
}
else
{
Response.Write("Not a number");
}

Hope this helps.
Tag: IsNumeric in C#, .NET

No comments:

Post a Comment