无法删除由streamReader.ReadLine添加的反斜杠 - c Sharp
我从文件中获得的文本具有以下字符串: 1"-DC-19082-A3
获取该行后,我得到以下字符串(在调试时获取): "\"1\"\"-DC-19082 -A3\""
当我在数据库上搜索时,它没有任何用处,我知道
如何才能回到原来的状态,
我已经看到 StreamWriter.WriteLine 可以完成这项工作,但我不想为此创建任何文件,
我尝试了以下方法,但它不起作用
StringBuilder sb = new StringBuilder();
sb.Append(@"\");
sb.Append('"');
string strToReplace = sb.ToString();
string lineNumberToSearchFor = lineNumber.Replace(strToReplace, string.Empty);
,希望有一种简单的方法可以实现这一目标,
非常感谢!
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(@"\");
sb.Append('"');
string strToReplace = sb.ToString();
string lineNumberToSearchFor = lineNumber.Replace(strToReplace, string.Empty);
hopefully there's an easy way of achieving this
many thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它添加反斜杠来指示字符串中间的引号。反斜杠实际上并不存在,而是引号。
如果您想删除引号:
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:
反斜杠是由“监视”窗口添加的。
字符串本身没有反斜杠。
The backslashes are added by the Watch window.
The string itself doesn't have backslashes.