1

Having an issue replacing a pipe with a double quote in a stringbuilder.

sbSql.Append("|" + State + "|"); string strSql = sbSql.ToString().Replace("|", "\""); 

Code above yields \"KS\" where I need it to be "KS" or whatever value is in State.

Ideas?

0

2 Answers 2

5

No, it doesn't. You only think that there are backslashes in front of the quotation marks because you are looking at the value in the debugger, which shows the string as you would write it as a string literal.

Sign up to request clarification or add additional context in comments.

2 Comments

It's creating a string to send as a method param. The parm has the \"KS\" value in it, which is incorrect. Thoughts?
@asp316: Try to print that text to the console or to a file, you will see that is just the debug watch that is cheating you ;) (debug watch shows also the escape chars)
2

If you are seeing \"KS\" in a debug window, you have "KS" in strSql (unless I am mistaken in how I am reading your question.)

1 Comment

@asp316: The watch window is part of the debugger.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.