1

How to do that from List ids in which 10 items in List cids, came in turn on 2 items?

internal List<items> test(List<long> ids)
{
    //ids = 10 items  
    List<long> cids = new List<long>(); // max 2 items in List<long> ids 

    var result= classA.GetValue(cids); //max cids items 2
    return result;
}
krlzlx
  • 5,752
  • 14
  • 47
  • 55
JonnyJon44
  • 73
  • 1
  • 11

2 Answers2

5

Is it really so simply? Use Take:

 internal List<items> test(List<long> ids)
 {
     return classA.GetValue(ids.Take(2).ToList()).Take(2).ToList();
 }

I dont know why you need to take 2 from the ids and pass these to GetValue as mentioned.

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
2

Using Linq,

var cids = ids.Take(2).ToList();

That's probably the simplest. Not much more to add... unless I gravely misunderstood the question.

Alex Paven
  • 5,539
  • 2
  • 21
  • 35