c#

How to Remove special characters

A
Desh-Duniya Team Author
| Published May 09, 2019
public static string RemoveSpecialCharacters(string str)
        {
            StringBuilder sb = new StringBuilder();
            foreach (char c in str)
            {
                if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
                {
                    sb.Append(c);
                }
            }
            return sb.ToString();
        }

Discussion (0)

Please sign in to participate in the discussion.
No comments yet. Be the first to join the conversation!