iBlog

Trevor Johnson
posts - 6 , comments - 12 , trackbacks - 0

My Links

News

Archives

Tuesday, March 29, 2011

C# IsNumeric

 My replacement for the the VB Function IsNumeric... 

 public static Boolean IsNumeric(string stringToTest)

{
    int result;
    if (int.TryParse(stringToTest, out result))
    {
        return true;
    }
    else
    {
        return false;
    }
}
 
Or even better... (thanks Anon)
 
public static Boolean IsNumeric(string stringToTest)
{
    int result;
    return int.TryParse(stringToTest, out result);
}

Posted On Tuesday, March 29, 2011 12:53 PM | Comments (9) |

Powered by: