Friday, June 27, 2008 2:37 PM
zowens
One-Line C# #1 : Remove Whitespace from a string
Thought I'd post a quick extension method that I made today. Hope it helps someone.
public static string RemoveWhitespace(this string str)
{ try
{ return new Regex(@"\s*").Replace(str, string.Empty);
}
catch (Exception)
{ return str;
}
}
Filed under: .NET, IL, C#, OneLine