Language:

IsNaturalNumber()

Language: Deutsch
Programming Language: C#
Published by: Thomas
Last Update: 5/4/2006
Views: 863

Description

Funktion prüft auf positive Ganzzahlen

Code

1 public static bool IsNaturalNumber(string strNumber) { 2 try { 3 Regex objNotNaturalPattern=new Regex("[^0-9]"); 4 Regex objNaturalPattern=new Regex("0*[1-9][0-9]*"); 5 return !objNotNaturalPattern.IsMatch(strNumber) && 6 objNaturalPattern.IsMatch(strNumber); 7 } 8 catch { 9 return false; 10 } 11 } 12

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS