How to extract numeric value from String?

 Posted by Rajesh_Kumar on 1/19/2014 | Category: C# Interview questions | Views: 683 | Points: 40
Answer:

We use Regex and its Match method to extract Number from String value.We have to create Regular Exp class object.and we have to pass string value to its Match method.We use \d used for extracting numeric value.

Regex regex = new Regex(@"\d+");

Match match = regex.Match("Rajesh Kumar Sathua Age 29");

if (match.Success)
{
MessageBox.Show(match.Value);
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response