日期:2014-05-17 浏览次数:20773 次
List<int> oldlist = new List<int>() { 0, 1, 2, 1, 2, 3, 2 };
List<List<int>> newlist = new List<List<int>>();
newlist = (from l in oldlist
group l by l into g
select g.Select(x => x).ToList()
).ToList();
List<int> list = new List<int>() { 0, 1, 2, 1, 2, 3, 2 };
var newlist = list.GroupBy(T => T).Select(t => t.ToList()).ToList();