【发布时间】:2015-06-27 13:24:25
【问题描述】:
我对 .NET 属性的理解存在漏洞。 Serializable 类的类定义是这样的:
namespace System {
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Delegate, Inherited = false)]
[ComVisible(true)]
public sealed class SerializableAttribute : Attribute {
public SerializableAttribute();
}
}
为什么当你使用它时它被称为 [Serializable] 而不是 [SerializableAttribute]?尽管您似乎可以使用后者。
这里是否存在某种别名?这将是一个“doh!”我怀疑的那一刻......
【问题讨论】:
-
谢谢 - 这是一个重复的问题。我搜索了属性别名而不是缩写。通常一半的问题是在你不知道答案时知道要搜索什么
标签: c# .net custom-attributes