C# Code Snippet - Validate whole number
(C-Sharp) C# code snippet to validate given whole number. IsWholeNumber function validates positive integers with zero inclusive. Function return TRUE if valid whole number found, if not function will return FALSE.
Bookmark:
C# Code Snippet - Validate whole number
This .Net C# code snippet validate whole number. This function uses regular expression to match string pattern to validate whole number.
public bool IsWholeNumber(string strNumber) { System.Text.RegularExpressions.Regex _RegexNotWholePattern = new System.Text.RegularExpressions.Regex("[^0-9]"); return !_RegexNotWholePattern.IsMatch(strNumber); }
C# Keywords Used:
- Regex
- IsMatch
Code Snippet Information:
- Applies To: .Net, C#, Whole Number Validation, Regular Expression
- Programming Language : C#
External Resources: