Questions tagged «debuggerdisplay»

3
C#调试:[DebuggerDisplay]还是ToString()?
有两种方法可以提高调试信息的有效性,而不是{MyNamespace.MyProject.MyClass}在调试器中查看。 这些是DebuggerDisplayAttribute和ToString()方法的使用。 using System.Diagnostics; ... [DebuggerDisplay("Name = {Name}")] public class Person { public string Name; } 要么 public class Person { public string Name; public override string ToString() { return string.Format("Name = {0}", Name); } } 有什么理由更喜欢另一种吗?有什么理由不做这两件事?纯粹是个人喜好吗?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.