C# 属性排除重复值
我有一个列表属性,它用System.Attribute类修饰。是否可以在属性级别对列表进行检查,使其仅包含不同的值C# 属性排除重复值,c#,.net,web-config,custom-attributes,C#,.net,Web Config,Custom Attributes,我有一个列表属性,它用System.Attribute类修饰。是否可以在属性级别对列表进行检查,使其仅包含不同的值 [ConfigSettingList(typeof(string),Description="Contains a list of supported handheld devices . Default is the below list .")] public List<string> HandHeldDevices {
[ConfigSettingList(typeof(string),Description="Contains a list of supported handheld devices . Default is the below list .")]
public List<string> HandHeldDevices
{
get
{
if (_handHeldDevices == null)
{
_handHeldDevices = new List<string> { "Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "IEMobile", "Opera Mini" };
}
return _handHeldDevices;
}
}
private List<string> _handHeldDevices;
[ConfigSettingList(typeof(string),Description=“包含受支持的手持设备的列表。默认值为以下列表。”)]
公共列表手持设备
{
收到
{
如果(_handHeldDevices==null)
{
_Handheldevices=新列表{“Android”、“webOS”、“iPhone”、“iPad”、“iPod”、“黑莓”、“IEMobile”、“Opera Mini”};
}
返回手持设备;
}
}
私人列表-手持设备;
ConfigSettingList继承自System.Attribute。我想检查不同的值。使用不允许重复的元素。这是什么意思?你能详细说明一下吗?用字典代替吗?请不要在问题标题中包含关于所用语言的信息,除非没有它就没有意义。标签就是为了这个目的。