I have a string from which I have to remove following char: \'\\r\', \'\\n\', and \'\\t\'. I have tried three different ways of removing these char and benchmarked them so I
try this
string str = "something \tis \nbetter than nothing"; string removeChars = new String(new Char[]{'\n', '\t'}); string newStr = new string(str.ToCharArray().Where(c => !removeChars.Contains(c)).ToArray());