Set all quotes to double quote using C#
08:48 10 Jun 2015

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("'''", "''");
    }
c# double-quotes quote