public bool IsInteger(string strNumber) { Regex objNotIntPattern = new Regex("[^0-9-]"); Regex objIntPattern = new Regex("^-[0-9]+$|^[0-9]+$"); return !objNotIntPattern.IsMatch(strNumber) && objIntPattern.IsMatch(strNumber); } |
Friday, October 03, 2008
IsInteger Function in C#
Subscribe to:
Post Comments (Atom)
1 comments:
thanks for posting this. Many coders that migrate from VB.NET to C# often include the libraries from VisualBasic.net so that they can use the functions IsNumeric, IsDate, etc etc.
This one is better solution...
Post a Comment