String - ExtractLetter
A string extension method that extracts the letter described by the string object.
public static void Main() { string input = "Mwasdf{123c[45z6]6c7v8}"; //C# Extension Method: String - ExtractLetter var output = input.ExtractLetter(); Console.WriteLine(output); }
View Source
using System; using System.Linq; public static partial class Extensions { /// <summary> /// A string extension method that extracts the letter described by @this. /// </summary> /// <param name="this">The @this to act on.</param> /// <returns>The extracted letter.</returns> public static string ExtractLetter(this string @this) { return new string(@this.ToCharArray().Where(x => Char.IsLetter(x)).ToArray()); } }