Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
197 views
in Technique[技术] by (71.8m points)

c# - 最有用的属性[关闭](Most Useful Attributes [closed])

I know that attributes are extremely useful.

(我知道属性非常有用。)

There are some predefined ones such as [Browsable(false)] which allows you to hide properties in the properties tab.

(有一些预定义的,例如[Browsable(false)]允许您在属性选项卡中隐藏属性。)

Here is a good question explaining attributes: What are attributes in .NET?

(这是一个很好的解释属性的问题: .NET中的属性是什么?)

What are the predefined attributes (and their namespace) you actually use in your projects?

(您在项目中实际使用的预定义属性(及其命名空间)是什么?)

  ask by community wiki translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

[DebuggerDisplay] can be really helpful to quickly see customized output of a Type when you mouse over the instance of the Type during debugging.

(在调试期间将鼠标悬停在Type的实例上时, [DebuggerDisplay]对于快速查看Type的自定义输出非常有用。)

example:

(例:)

[DebuggerDisplay("FirstName={FirstName}, LastName={LastName}")]
class Customer
{
    public string FirstName;
    public string LastName;
}

This is how it should look in the debugger:

(这是它应该在调试器中查看的方式:)

替代文字

Also, it is worth mentioning that [WebMethod] attribute with CacheDuration property set can avoid unnecessary execution of the web service method.

(另外,值得一提的是,具有CacheDuration属性集的[WebMethod]属性可以避免不必要的Web服务方法的执行。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...