开发者

cannot remove backslashes added by streamReader.ReadLine - c sharp

the text I've got from the file has the following string: 1"-DC-19082-A3

after getting that line I get the following string (got it while debugging): "\"1\"\"-DC-19082-A3\""

as I'm searching on the DB it's not of any use like that

any idea how can I get back to the original?

I've seen that StreamWriter.WriteLine would do the job, but I don't want to create any file for this.

I tried the following, but it didn't work

StringBuilder sb = new StringBuilder();
sb.Append(开发者_JS百科@"\");
sb.Append('"');
string strToReplace = sb.ToString();
string lineNumberToSearchFor = lineNumber.Replace(strToReplace, string.Empty);

hopefully there's an easy way of achieving this

many thanks!


It adds the backslashes to indicate quotes in the middle of the string. The backslashes aren't actually there, the quotes are.

If you want to remove the quotes instead:

myString.Replace("\"", string.Empty);


The backslashes are added by the Watch window.
The string itself doesn't have backslashes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜