【问题标题】:System.Attribute exclude duplicate valuesSystem.Attribute 排除重复值
【发布时间】:2014-03-04 06:07:59
【问题描述】:

我有一个用 System.Attribute 类装饰的列表属性。是否可以在属性级别对列表进行检查以仅包含不同的值?

[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 继承自 System.Attribute 。我想检查不同的值。

【问题讨论】:

  • 你这是什么意思?你能详细说明一下吗?
  • 改用字典
  • 请不要在问题标题中包含有关所用语言的信息,除非没有它就没有意义。标记用于此目的。

标签: c# .net web-config custom-attributes


【解决方案1】:

使用不允许重复元素的HashSet&lt;T&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-01
    • 1970-01-01
    • 2020-05-10
    • 1970-01-01
    • 2014-02-10
    • 1970-01-01
    • 1970-01-01
    • 2021-05-28
    相关资源
    最近更新 更多