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