Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Watch Window in 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 = new Point(10 ,10) will display on the Value column in Watch : {X = 10 Y = 10}.

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

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

like image 355
paccic Avatar asked Feb 23 '23 12:02

paccic


1 Answers

See Using DebuggerDisplay Attribute

If you have marked class by an attribute:

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

Output appearing in the Value column of Watch window will be like following:

x = 5 y = 18
like image 196
sll Avatar answered Mar 03 '23 02:03

sll