How to get ToString() to show up in Debug

前端 未结 7 1076
情话喂你
情话喂你 2020-12-15 21:34

I\'d like to get ToString() to display for a class under my control in debug mode.

It\'d be nice if this was the first thing to show up when you hover over a varia

7条回答
  •  再見小時候
    2020-12-15 22:19

    in the object Override the .ToString as follows:

    public class MyObject
    {
            public int Property1{ get; set; }
            public string Property2{ get; set; }
            public string Property3 { get; set; }
    
            public override string ToString()
            {
                return Property3;
            }
    }
    

    This will return Property3 as the ToString() value

提交回复
热议问题