标签:var remove site list class res UNC tin color
public class GroupHelper { public class ListGroup { public static List<List<object>> Group(List<object> source, Func<List<object>, bool> limitFunc) { return Group<object>(source, limitFunc); } /// <summary> /// 分组 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="source">源</param> /// <param name="limitFunc">项限制</param> /// <returns></returns> public static List<List<T>> Group<T>(List<T> source, Func<List<T>, bool> limitFunc) { var remainder = source.ToList(); var result = new List<List<T>>(); List<T> resItem = null; foreach (var item in source.Except(remainder)) { remainder.Add(item); if (resItem == null) { resItem = new List<T> { item }; } resItem.Add(item); resItem = resItem.Distinct().ToList(); if (!limitFunc(resItem.ToList())) { resItem.Remove(item); result.Add(resItem); } } if (resItem != null) { result.Add(resItem); } return result; } } }
标签:var remove site list class res UNC tin color
原文地址:https://www.cnblogs.com/zhuwansu/p/10249150.html