我知道标题很困惑,所以我会尽力在这里解释......
我有
class T{
int id;
string value;
}
List<T> objs;
在我的代码中,当我检索初始列表时,我使用
获取第一个 idint currentID = objs.FirstOrDefault().id;
现在我需要捕获下一个。不知道我当前所在的位置如何获取下一个项目 ID...
objs.select(x => x.id)
.where(//you are the object that exists after the one with currentID);
请您参考如下方法:
如果你想在某个元素之后获取下一个元素,那么你可以使用 SkipWhile() 和 Skip() 方法:
objs.SkipWhile(x => x.id == currentID).Skip(1).FirstOrDefault();
