Skip to main content
Jun 12, 2013
/// <summary>
/// Method checks if passed string is integer
/// </summary>
/// <param name="text">string text for checking</param>
/// <returns>bool - if text is integer return true, else return false</returns>
public bool IsNumber(string text)
{
    int num = 0;
    bool isNum = false;
  
    // Check for empty string.
    if (string.IsNullOrEmpty(text))
    {
        return false;
    }
  
    isNum = int.TryParse(text, out num);
  
    return isNum;
}