How does the VIsual Studio watch window gets the value for a variable?
Lets say I have a variable x of type ABC instantiated. When I see the value of x it shows me the value from the x.ToString() method.
Where else the value displayed in the value column could come from?
Any help appreci开发者_开发问答ated,
Thanks,
Dattebayo
The text you see under the Value column in the Watch window could come from one of three sources.
- The object's ToString() method, as you've mentioned
- A DebuggerDisplayAttribute on the type ABC, which tells the debugger how to present it to the user.
- If your "ABC" class is decorated with a DebuggerTypeProxy attribute, you would see either the .ToString or the DebuggerDisplay string that the proxy type has.
To the best of my knowledge, those are the only three options.
精彩评论