c# - Possible to group by Count in LINQ? -


It can be impossible or so clear that I keep it over.

I have a list of objects (we call ints for this example):

  list & lt; Int & gt; List = new list & lt; Int & gt; () {1, 2, 3, 4, 5, 6};  

I do not add any relation to any kind in the order of returning a new organizing object.

that is,

  list.GroupBy (i = & gt; someLogicToProductPairs); There is a very real possibility that I can reach this problem from the wrong angle, although the goal is to create a group of objects with an ongoing capacity. Any help is greatly appreciated.   

Do you mean:

  from the list & lt; Integer & gt; List = new list & lt; Int & gt; () {1, 2, 3, 4, 5, 6}; IEnumerable & LT; IGrouping & LT; Integer, integer & gt; & Gt; Group = list. Select ((n, i) = & gt; new {group = i / 2, value = n}) .GroupBy (g = & gt; g group, g = & gt; g. Valle); Fortecha (IGrouping & lt; int, int & gt; Groups in Groups) {Console.WriteLine (String.Join (",", Select Group (n = & gt; n.ToString ()) ToArray ()) ); }  

Output

  1, 2 3, 4 5, 6  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -