码迷,mamicode.com
首页 > Windows程序 > 详细

C#.NET为List加入扩展方法:获取唯一值

时间:2017-07-29 20:50:26      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:eva   value   public   class   har   get   this   count   for   

    public static class ListTools
    {
        /// <summary>
        /// 获取唯一值列表
        /// </summary>
        /// <param name="strList">原始值</param>
        /// <returns>唯一值</returns>
        public static List<T> GetUniqueValue<T>(this List<T> list)
        {
            List<T> tmp = new List<T>();
            for (int i = 0; i < list.Count; i++)
            {
                if (!tmp.Contains(list[i]))
                    tmp.Add(list[i]);
            }
            return tmp;
        }
    }

C#.NET为List加入扩展方法:获取唯一值

标签:eva   value   public   class   har   get   this   count   for   

原文地址:http://www.cnblogs.com/mfmdaoyou/p/7257369.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!