Skip to content

Commit ce5f7e6

Browse files
committed
Add Slice for listing
1 parent cc2bfc7 commit ce5f7e6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Source/FikaAmazonAPI/Utils/Listing.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
4+
namespace FikaAmazonAPI.Utils
5+
{
6+
public static class Listing
7+
{
8+
public static IList<IList<T>> Slice<T>(IList<T> list, int number)
9+
{
10+
IList<IList<T>> objListList = new List<IList<T>>();
11+
int num = list.Count / number;
12+
if ((uint)(list.Count % number) > 0U)
13+
++num;
14+
for (int index = 0; index <= num - 1; ++index)
15+
{
16+
IList<T> list1 = list.Skip<T>(index * number).Take<T>(number).ToList<T>();
17+
objListList.Add(list1);
18+
}
19+
return objListList;
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)