【发布时间】:2013-03-21 06:32:48
【问题描述】:
我有一个枚举,其中一些成员由自定义属性标记,例如:
public enum VideoClipTypeEnum : int
{
Exhibitions = 1,
TV = 2,
[ClipTypeDisplayAttribute(false)]
Content = 3
}
我的属性是:
public class ClipTypeDisplayAttribute : DescriptionAttribute
{
#region Private Variables
private bool _treatAsPublicType;
#endregion
#region Ctor
public ClipTypeDisplayAttribute(bool treatAsPublicType)
{
_treatAsPublicType = treatAsPublicType;
}
#endregion
#region Public Props
public bool TreatAsPublicType
{
get
{
return _treatAsPublicType;
}
set
{
_treatAsPublicType = value;
}
}
#endregion
}
将用我的自定义属性标记的成员的值放入列表的最佳方法是什么?
【问题讨论】:
-
你能说得更具体点吗?您的示例中没有字段-您是在谈论枚举成员吗?您是否只想接收带有属性标记的枚举成员?
-
没错!成员...对不起那个陷阱)
标签: c# enums custom-attributes