首页 文章
  • 393 votes
     answers
     views

    获得Enum Value 的属性

    我想知道是否可以获取枚举值的属性而不是枚举本身的属性?例如,假设我有以下枚举: using System.ComponentModel; // for DescriptionAttribute enum FunkyAttributesEnum { [Description("Name With Spaces1")] NameWithoutSpaces1, ...
  • 458 votes
     answers
     views

    为什么C#禁止通用属性类型?

    这会导致编译时异常: public sealed class ValidatesAttribute<T> : Attribute { } [Validates<string>] public static class StringValidation { } 我意识到C#不支持通用属性 . 然而,经过大量的谷歌搜索,我似乎无法找到原因 . 有谁知道为什么泛型类型不能...
  • 749 votes
     answers
     views

    最有用的属性[关闭]

    我知道属性非常有用 . 有一些预定义的,例如 [Browsable(false)] ,它允许您在属性选项卡中隐藏属性 . 这是一个解释属性的好问题:What are attributes in .NET? What are the predefined attributes (and their namespace) you actually use in your projects?

热门问题