开发者

How to select the first three elements of a IEnumerable object?

开发者 https://www.devze.com 2023-01-17 03:00 出处:网络
That\'s it. The question is in the title I was looking for a cleaner way than the u开发者_运维问答sing for...break;

That's it. The question is in the title

I was looking for a cleaner way than the u开发者_运维问答sing for...break;

thanks


This should do it!

var items = new List<int>(){ 1, 2, 3, 4, 5 };
var results = items.Take(3);
0

精彩评论

暂无评论...
验证码 换一张
取 消