# C Sharp - Useful methods - 2 [ GetNumeric]

Posted by in C# category on for Intermediate level | Views : 5565

GetNumeric Function

This method will return the digits between the strings, if no digits found it returns 0
###### Introduction

GetNumeric Function

This method will return the digits between the strings, if no digits found it returns 0

`        /// <summary>        /// GetNumeric Function        /// This method will return the digits between the strings, if no digits found it returns 0        /// </summary>        /// <param name="expression"></param>        /// <returns></returns>        public static string GetNumeric( string expression )        {            bool found = false;            string returnValue = "";            foreach ( char c in expression )            {                if ( Char.IsNumber( c ) )                {                    returnValue += c;                    found = true;                }            }            if ( found == false )            {                returnValue = "0";            }            return returnValue;        }`

## About the Author

Full Name: Deepak Rao
Member Level: Starter
Member Status: Member
Member Since: 2/4/2009 10:10:50 PM
Country:

www.deepakrao.co.nr
I am an Indian Guy , working as Software Consultant in Bangalore . I am typical average programmer. One of those millions who earn their bread and butter from programming. I'm a software developer by profession, and I have a passion for books and music I am elder son to my parents, with an younger brother. Like most people, it's complicated thing to describe me. I am just inimitable, like many others. But I'll do the best I can to describe myself with words. I know that I am quite a smart person on most things, and also am exceedingly imaginative. I do feel that I am funny, though surely not everyone is funny all the time. My humor would probably best be labeled very wry and sarcastic, though it is quite fun to just plain laugh at the silliness of things lots of times.

Login to vote for this post.

#### Comments or Responses

Comment using (Author doesn't get notification)