最有用的特征 [英] Most Useful Attributes

查看:196
本文介绍了最有用的特征的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道属性是非常有用的。还有一些pdefined $ P $的,如 [可浏览(假)] ,它允许您隐藏在属性选项卡中的属性。这是一个很好的问题,解释属性: .NET:?什么是属性

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. Here is a good question explaining attributes: .NET: What are attributes?

什么是predefined属性(和它们的命名空间),你实际上是在你的项目中使用?

推荐答案

[DebuggerDisplay] 可以是真正有用的迅速看到一个类型的自定义输出,当你把鼠标移到例如在调试过程中的类型。例如:

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

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

这是它应该如何看在调试器:

This is how it should look in the debugger:

此外,值得一提的是, [WebMethod的] 属性与 CacheDuration 属性设置可避免不必要的执行Web服务方法。

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

这篇关于最有用的特征的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆