转义字符在调试器(C#)中不起作用 [英] Escape Characters Aren't Working In Debugger (C#)

查看:79
本文介绍了转义字符在调试器(C#)中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用转义符来打印双引号.但是,我的程序抛出错误,因此我正在尝试对其进行调试.当我使用转义字符向字符串添加手表时,它表明字符串文字中包含反斜杠.如何使用转义字符,以使\不会成为文字的一部分?

I'm trying to use escape characters to print a double quote. However, my program is throwing an error so I'm trying to debug it. When I add a watch to a string using an escape character it shows that the backslash is being included in the string literal. How do I use escape characters so that the \ doesn't become part of the literal?

推荐答案

您对调试器的行为感到困惑.

You are confused by the debugger's behavior.

VS调试器将在 Watch 部分以及将鼠标悬停时显示带有转义符(例如: 4 \")的值,但是该代码将正确使用 4"

VS debugger will show the value with the escape character (Ex: 4\") in the Watch section and on hovering but the code will properly use 4"

在上图中,您可以注意到VS已将其与转义符一起显示,但可以在控制台中正确显示.

In the picture above, you can notice it's shown with the escape character by VS but displays correctly in the console.

这篇关于转义字符在调试器(C#)中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆