0

I get an array with some number of elements. When there are more than ten elements in the array, then I need to create a new array.

For example we have the collection:

var list = var list = new List<int> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

I expect such a result:

list1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

list2 = {11, 12, 13}

seph0z
  • 11
  • 3

1 Answers1

0

You can simply use Take and Skip as follow:

var list1 = list.Take(10).ToList();
var list2 = list.Skip(10).ToList();
Selim Yildiz
  • 5,254
  • 6
  • 18
  • 28