Trying to write a method that splits a list into sublists.
Private Function SplitIdsIntoChunks(ByVal keys As List(Of String)) As List(Of List(Of String))
Return keys _
.Select(Function(x, i) New With {Key .Index = i, Key .Value = x}) _
.GroupBy(Function(x) (x.Index / 10000)) _
.Select(Function(x) x.Select(Function(v) v.Value).ToList()) _
.ToList()
End Function
I used C# solution from here. C# solution works fine.
My version written in VB returns a collection of lists with one element instead of 10000. Where did I go wrong?
Thanks in advance.
Edit 1:
Usage:
Dim chunks As List(Of List(Of String)) = SplitIdsIntoChunks(keys)
'Keys' content:
My method returns a lists of lists with one item inside:
Expected result: list of two lists - 10000 items in first and 6256 in second.