You are supposed to use Replace() method instead of Trim()
Trim eliminates leading and trailing whitespace. We need to remove whitespace from the beginning or ending of a string. We use the .NET Framework's Trim method to do this efficiently. This method removes any characters specified.
string input = "Hi,I'm a sentence having special characters.;";
input = input.Replace("'", "").Replace(",", "").Replace(";", "").Replace(".", "");