I have a list of strings which has got some characters in it.

On viewing it in HTML viewer I get the following

I tried line.Replace() to remove some special characters but it doesn't work.
I have a list of strings which has got some characters in it.

On viewing it in HTML viewer I get the following

I tried line.Replace() to remove some special characters but it doesn't work.
 
    
     
    
    This code will remove any non-printable or non-ASCII characters using regex:
line = Regex.Replace(line, @"[^\u0021-\u007F]", string.Empty);
 
    
    You can filter it lke this :
var specialChars = new char[] {'-', '!', '*'}; // your all special chars
var newstr = string.Concat(line.ToCharArray().Where(c => !specialChars.Contains(c)));
Hope this helps.
