Visual Studio中的监视窗口 [英] Watch Window in Visual Studio

查看:464
本文介绍了Visual Studio中的监视窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以指定要在监视窗口"中查看的对象的哪些成员,而无需使用所有属性扩展树.例如:

Is there a way to specify what members of an object to see in Watch Window without expanding the tree with all the properties. For example:

p =新的Point(10,10)将显示在Watch的值"列中: {X = 10 Y = 10} .

p = new Point(10 ,10) will display on the Value column in Watch : {X = 10 Y = 10}.

对于我自己的类,它始终显示: {MyNamespace.MyClass}或{MyNamespace.MyStruct} .

For my own classes it always displays : {MyNamespace.MyClass} or {MyNamespace.MyStruct}.

我可以更改它以便显示: {MyStringProperty =" MyIntProperty = 0 ...} 吗?

Could I change this in order to display : { MyStringProperty = "" MyIntProperty = 0 ... } ?

推荐答案

请参见使用DebuggerDisplay属性

如果您已通过属性标记班级:

[DebuggerDisplay("x = {X} y = {Y}")]
public class MyClass
{
   public int X { get; private set; }
   public int Y { get; private set; }
}

出现在监视"窗口的值"列中的输出将如下所示:

x = 5 y = 18

这篇关于Visual Studio中的监视窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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