CSharp examples for System:String Strip
Remove Special Characters
using System.Text; public class Main{ public static string RemoveSpecialCharacters(string str) {//w w w .ja v a 2s . c o m StringBuilder sb = new StringBuilder(); foreach (char c in str) { if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '.' || c == '_' || c == '-'||c == ' ') { sb.Append(c); } } return sb.ToString(); } }