0

I have a string that has the value /Daily". and the parameter that i'm trying to pass into my application is /Daily. However after trying a few methods to remove the quote, nothing seems to be working.

Methods used

  • .remove('"');
  • .replace("\"");
  • .trim('"');
Chrislaar123
  • 323
  • 2
  • 6
  • 17

1 Answers1

5

Remember that strings in .NET are immutable, so calling the Replace method doesn't actually change the underlying string--it returns a value that represents a new string based on the Replace operation. You'll need to capture that returned value for this to work:

var str = "/Daily\"";
str = str.Replace("\"", "");

Also notice that quotes are escaped by backslashes (\) in C#, rather than forward-slashes.

StriplingWarrior
  • 151,543
  • 27
  • 246
  • 315