I know this post is old, but you can shorten Stephen C a bit using the System.Char structure.
public String RemoveNonAlphaNumeric(String value) { StringBuilder sb = new StringBuilder(value); for (int i = 0; i < value.Length; i++) { char ch = value[i]; if (Char.IsLetterOrDigit(ch)) { sb.Append(ch); } } return sb.ToString(); }
Still doing the same thing more compactly.
Char has some really great features for checking text. Here are some of your future links.
Char.GetNumericValue() Char.IsControl() Char.IsDigit() Char.IsLetter() Char.IsLower() Char.IsNumber() Char.IsPunctuation() Char.IsSeparator() Char.IsSymbol() Char.IsWhiteSpace()
source share