Reputation: 9970
I have a text box on my web page which I want to allow the user to type double quotes in.
It's a web report kind of deal.
So users can enter in
breaking
or
"breaking"
if they want to capture the exact word.
The issue is, when I look at the variable when I try to do "breaking"
, I keep getting this:
"\"breaking bad\""
I need to get "breaking bad"
...
How do I go about doing this properly? Is there NOT a way to do this and therefore I have to simply do a replace?
Upvotes: 0
Views: 254
Reputation: 2253
This is how the debugger displays it. If you want to see the real version quickly, click on the loupe next to the value you're displaying in the debugger.
Upvotes: 0
Reputation: 152634
when I look at the variable when I try to do "breaking", I keep getting this:
"\"breaking bad\""
If by "looking" you mean in the debugger, then what you are seeing is the debugger escaping the quotes by adding the backslashes. If you output that string to the console, a form, database, etc. It will be surrounded by quotes just as you'd expect it to.
Upvotes: 2
Reputation: 15285
The backslashes that you are seeing are just Visual Studio's way of displaying quotes inside a string when using the debugger to inspect a variable. You are getting the correct value. If you use the 'Text Visualizer' feature in the debugger to examine the string, you'll see that the backslashes aren't really there.
Upvotes: 4