-2

I'm trying to replace double consecutive single quotation marks to null, like this:

//my string is " replace '' to null "
str.Replace("''", "null");
//now my string is " replace null to null "

But this is happening:

//my string is " replace '' to null "
str.Replace("''", "null");
//sadly my string still is " replace '' to null "

Any tips?

fkupper
  • 520
  • 3
  • 9

1 Answers1

2

string.Replace does not modify input string instead - it returns a new one instead. Reassign it back to your variable to see the change.

str = str.Replace("''", "null");
MarcinJuraszek
  • 124,003
  • 15
  • 196
  • 263