Have better than: IsInt(string value)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • skneife@gmail.com

    #1

    Have better than: IsInt(string value)

    Does anyone have a better way for knowing if a string contains an
    int ?

    bool IsInt(string valeur)
    {
    bool result = false;
    try {
    int.Parse(valeu r);
    result = true;
    }
    catch {}
    return result;
    }

    Sam

  • Jon Skeet [C# MVP]

    #2
    Re: Have better than: IsInt(string value)

    On Nov 14, 9:08 am, skne...@gmail.c om wrote:
    Does anyone have a better way for knowing if a string contains an
    int ?
    If you're using .NET 2.0, use int.TryParse.

    Jon

    Comment

    Working...