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#扩展List获取唯一值.zip
C#.NET为List添加扩展方法:获取唯一值
时间: 2024-12-10 15:33:57