String - IsAlpha
A string extension method that query if the string object is Alpha.
public static void Main() { string [] values = {"EntityFramework", "EntityFramework6"}; foreach(var str in values) { // C# Extension Method: String - IsAlpha if(str.IsAlpha()) { Console.WriteLine("{0} is Alpha", str); } else { Console.WriteLine("{0} is not Alpha", str); } } }
View Source
using System.Text.RegularExpressions; public static partial class Extensions { /// <summary> /// A string extension method that query if '@this' is Alpha. /// </summary> /// <param name="this">The @this to act on.</param> /// <returns>true if Alpha, false if not.</returns> public static bool IsAlpha(this string @this) { return !Regex.IsMatch(@this, "[^a-zA-Z]"); } }