如何更改在调试器输出的一类? [英] How do I change the output in the debugger for a class?

查看:173
本文介绍了如何更改在调试器输出的一类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一类的ToString()方法输出在调试器中类的信息,但它改变了用户界面(UI)的输出不幸的副作用。有没有可以在类中指定的属性?

The ToString() method for a class outputs the class information in the debugger but it has the unfortunate side effect of changing the output for the User Interface (UI). Is there an attribute that can be specified on the class?

推荐答案

使用属性DebuggerDisplay

Use the attribute DebuggerDisplay

[DebuggerDisplay("AnyString: {MyVar}")]

这代码将有调试器类显示:

This code will have the debugger for your class display:

AnyString:12

AnyString: 12

其中MyVar的已分配值12。

where MyVar has been assigned the value 12.

这篇关于如何更改在调试器输出的一类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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