.Net extract digits from a string

Here’s how we can extract digits from a string:


public static string ExtractDigits(string input)
{
    return new String(input.Where(x => x >= '0' && x <= '9').ToArray());
}

Leave a Reply

Your email address will not be published. Required fields are marked *