I try to make it possible for users to search for customers with a quote in the CustomerName.
The user search the user in the customerNameTextBox which is set to the customerNameTB.
If the user uses a quote(') it will be replaced with a double-quote.
And if there is a triple quote(''') it will be replaced with a double-quote.
Here is my code:
string customerNameTB = customerNameTextbox.Text;
customerNameTB.Replace("'", "''");
while (customerNameTB.Contains("'''"))
{
customerNameTB.Replace("'''", "''");
}
The result after this code is the quotes are still single quotes.
What is wrong with this little piece of code?
Edit after answers
My code should look like this:
string customerNameTB = customerNameTextbox.Text;
customerNameTB = customerNameTB.Replace("'", "''");
while (customerNameTB.Contains("'''"))
{
customerNameTB = customerNameTB.Replace("'''", "''");
}