using System.Diagnostics;
namespace ShouldCode.Console
{
[DebuggerDisplay("Prop1:{Prop1};Prop2:{Prop2};")]
public class ShouldDebuggerDisplay {
public int Prop1 { get; set; }
public string Prop2 { get; set; }
public static void Debug()
{
var debugger1 = new ShouldDebuggerDisplay
{
Prop1 = 1,
Prop2 = "2"
};
var debugger2 = new NotToString
{
Prop1 = 1,
Prop2 = "2"
};
var debugger3 = new DefaultDisplay();
//调试时显示窗口的值是 type.fullname 其中 ojbect is object
var defDisplay = typeof(DefaultDisplay).FullName;
var tostring = debugger3.ToString();//ShouldCode.Console.DefaultDisplay
// breakpoint here to see debugger
System.Console.ReadLine();
}
}
public class NotToString
{
public int Prop1 { get; set; }
public string Prop2 { get; set; }
public override string ToString()
{
return $"Prop1:{Prop1};Prop2:{Prop2};";
}
}
public class DefaultDisplay { }
}