Getting Started with Adobe After Effects - Part 6: Motion Blur
A collection of quick technology learning tips from what people around you learn every day

c# - Extension method to check numeric value or not

Jul 1 2011 12:22AM by Ramireddy   

C# 3.0 introduced the concept of extension methods. By using this feature, we can add various utility methods to the CLR types. few times, in our application we wants to check whether the value entered by user is numeric or not. Here is an example of adding an extension method to string type and checking it.

public static class Extensions
{
    public static bool IsNumeric(this string str)
    {
        Regex _isNumber = new Regex(@"^\d+.\d+$");
        Match m = _isNumber.Match(str);
         return m.Success;

    }
}
        string valtotest = "123.12";
        Response.Write(valtotest.IsNumeric());
Read More..   [8 clicks]

Published under: Microsoft .NET Tips ·  ·  ·  · 


Ramireddy
2 · 41% · 12972
2
 
2
 
 
0
Incorrect
 
0
Interesting
 
0
Forgotten



Submit

Your Comment


Sign Up or Login to post a comment.

"c# - Extension method to check numeric value or not" rated 5 out of 5 by 2 readers
c# - Extension method to check numeric value or not , 5.0 out of 5 based on 2 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]