C# string to alphanumeric
Short and easy way to get the alphanumeric content of a string:
public static string ToAlphaNumeric(this string str)
{
return new string(str.Where(c => char.IsLetterOrDigit(c)).ToArray());
}
Just another WordPress codeblog on C#, Silverlight and all things .NET
Short and easy way to get the alphanumeric content of a string:
public static string ToAlphaNumeric(this string str)
{
return new string(str.Where(c => char.IsLetterOrDigit(c)).ToArray());
}
I realise now that it might be bad practice to rely on the order in which Where returns items.
larsholm
25 Jan 13 at 2:40 pm