C# .NET: Split a String, Trim, and ToLower All Elements

7/23/2014 1:13:25 AM

The following will take a comma delimited string, trim, and toLower() all of the resulting elements. This will

string commaDelimitedString = "a, B, C, d, E";
    List<string> elements = commaDelimitedString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim().ToLower()).ToList();