ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

ContainsNumericChars

returns true if string contains numeric chars

Source

public static class ext
{
    public static bool ContainsNumericChars(this string s)
    {
      return  s.IndexOfAny("0123456789".ToArray())>=0;
    }
}

Example

string s = "sdfsdfsf";
bool b = s.ContainsNumericChars();

Author: UnstableMutex

Submitted on: 21 okt. 2013

Language: C#

Type: String

Views: 4895