I'm new in programming and this is my first project and I'm using C#. Basically I tryed to do a function that insert one more single quote in string that already have a single quote, but this is crashing my program and I don't know why.
The function:
private string CheckSingleQuote(string txt)
{
for (int i = 0; i < txt.Length; i++)
if (txt[i] == '\'')
txt = txt.Insert(i, "'");
return txt;
}
When I click in a specific button, this function is called ten times to set the value of the strings.