限制项目列表c#

Jon*_*n44 1 .net c# asp.net items list

如何从列表 ids 中做到这一点,其中列表 cids 中的 10 个项目依次出现在 2 个项目上?

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;
}
Run Code Online (Sandbox Code Playgroud)

Tim*_*ter 5

事情真的有这么简单吗?使用Take

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

我不知道为什么你需要从 ids 中取出 2 个并将它们传递给GetValue如上所述。