2010-01-25

一个有用的C# Attribute: DebuggerDisplay


namespace ConsoleApplication2
{
[DebuggerDisplay("count ={Count}")]
public class Test
{
public int Count{ get; set;}
public string Name { get; set; }
public void Clear()
{
}
}
}


如上代码示例所示,该属性可以让对象在鼠标悬停时按格式显示Count字段的值,而不必点开对象查找,当对象有非常多的Property时,这个属性尤其有用

No comments: