Function for removing unwanted characters
Only approved characters in the string OKChars.
private string Clean(string text) {
string OKChars="abcdefghijklmnopqrstuvwxyzåäöABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ1234567890 _-";
StringBuilder sb = new StringBuilder();
foreach (char c in text.Trim().ToCharArray())
if (OKChars.Contains(c.ToString()))
sb.Append(c);
return sb.ToString();
}
Written by Marcus Olsson
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#String
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#