Here I will explain how we can remove the special characters from the given string in simple way.
First create a method
public string RemoveSpecialChars(string str)
{
// Create a string array and add the special characters you want to remove
You can include / exclude more special characters based on your needs
string[] chars = new string[] { ",", ".", "/", "!", "@", "#", "$", "%", "^", "&", "*", "'", "\"", ";","_", "(", ")", ":", "|", "[", "]" };
//Iterate the number of times based on the String array length.
return str;
}
Example:
If you have a string like "$['Suri']"
Now will see how can we use that method
string str = "$['Suri']";
string withoutspecialcharacters = RemoveSpecialChars(str);
//now the output is: Suri