Advertisement
Atheuz

Untitled

Nov 11th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. List<List<Review>> returnList = new List<List<Review>>();
  2.             int partitionSize;
  3.            
  4.             if (numberOfPartitions > 0)
  5.             {
  6.                 partitionSize = (int)Math.Ceiling((decimal)reviews.Count / (decimal)numberOfPartitions);
  7.             }
  8.             else
  9.             {
  10.                 partitionSize = reviews.Count;
  11.             }
  12.  
  13.             for (int i = 0; i < numberOfPartitions; i++)
  14.             {
  15.                 if (i == numberOfPartitions - 1)
  16.                 {
  17.                     returnList.Add(reviews.Skip(partitionSize * i).ToList());
  18.                 }
  19.                 else
  20.                 {
  21.                     returnList.Add(reviews.Skip(partitionSize * i).Take(partitionSize).ToList());
  22.                 }
  23.             }
  24.  
  25.             return returnList;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement