Tuesday, July 1, 2014

Extension Methods in C#

 public void TestMethod()
        {
            string strNumber = "4";
            bool isNumeric = strNumber.IsNumeric();
        }


 public static class ExtensionMethods
    {
        public static bool IsNumeric(this string str)
        {
            float Numeric;
            return float.TryParse(str, out Numeric);
        }
    }

No comments:

Post a Comment

Comments

Search

Custom Search
Protected by Copyscape Plagiarism Software