Monday, July 13, 2009

How to check if there is any alphabet or non alphanumeric character in a string

Sometimes in our Project we may need to check if a particular string can be converted to a number or not.

In practical world any string can be converted as Number if it contains only number Or essentially it should not contain any non alphanumeric character or alphabet.

In my project, I faced a problem while creating search and Match engine, I needed to match a string with Salary column when it is eligible for getting converted to a number. I had seen many approaches on internet but then decided to write my own to make it very easy.

I have written the following C# code with the help of Regex class to achieve the same.

See full detail:

No comments: