Checking if a string is a numeric value


Recently I needed to validate a string input by a user to ensure it was in a specific format.  One of the requirements was that after the first character, all of the rest of the input must be numeric.  Here is how you can accomplish this:

string tag  = “S127437”; //Your input string goes here

alphatag = tag.Substring(1,tag.Length-1);
bool isalpha = double.TryParse(alphatag, out Num);

 Using the TryParse function allows you to see if a passed in string will convert properly into the Double datatype.  An easy bit of code to use to validate for a numeric input.


Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!