using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; namespace Pcb.Common { /// /// 列表扩展 /// /// public static class extEnumerable { #region 转换成散列集合 /// /// 转换成HashSet /// /// 列表项类型 /// 枚举列表 /// HashSet public static HashSet _ToHashSet(this IEnumerable List) { var hs = new HashSet(); foreach (var i in List) { hs.Add(i); } return hs; } /// /// 转换成HashSet /// /// 列表项类型 /// 枚举列表 /// HashSet public static HashSet _ToHashSet(this IEnumerable List) { var hs = new HashSet(); foreach (T i in List) { hs.Add(i); } return hs; } /// /// 转换成HashSet /// /// 列表项类型 /// 其它类型 /// 枚举列表 /// 选择键函数 /// 数组 public static HashSet _ToHashSet(this IEnumerable List, Func Select) { var hs = new HashSet(); foreach (var i in List) { hs.Add(Select(i)); } return hs; } /// /// 转换成HashSet /// /// 列表项类型 /// 其它类型 /// 枚举列表 /// 选择键函数 /// 数组 public static HashSet _ToHashSet(this IEnumerable List, Func Select) { var hs = new HashSet(); foreach (T i in List) { hs.Add(Select(i)); } return hs; } /// /// 转换成其它类型列表 /// /// 其它类型 /// 数据行列表 /// 选择键函数 /// 列表 public static HashSet _ToHashSet(this System.Data.DataRowCollection List, Func Select) { HashSet lst = new HashSet(); foreach (System.Data.DataRow i in List) { lst.Add(Select(i)); } return lst; } /// /// 转换成其它类型列表 /// /// 其它类型 /// 数据行列表 /// 选择键函数 /// 列表 public static HashSet _ToHashSet(this System.Data.DataColumnCollection List, Func Select) { HashSet lst = new HashSet(); foreach (System.Data.DataColumn i in List) { lst.Add(Select(i)); } return lst; } #endregion } }