Language:

IsInteger()

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

Description

Funktion prüft sowohl auf positive, als auch auf negative Ganzzahlen

Code

1 public static bool IsInteger(string strNumber) { 2 try { 3 Regex objNotIntPattern=new Regex("[^0-9-]"); 4 Regex objIntPattern=new Regex("^-[0-9]+$|^[0-9]+$"); 5 return !objNotIntPattern.IsMatch(strNumber) && objIntPattern.IsMatch(strNumber); 6 } 7 catch { 8 return false; 9 } 10 } 11

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS