获得IEnumerable< T>的最佳方法是使用IEnumerable [英] The best way to get a count of IEnumerable<T>

查看:77
本文介绍了获得IEnumerable< T>的最佳方法是使用IEnumerable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在不枚举IEnumerable集合中所有项目的情况下,最好/最简单的方法是什么?

Whats the best/easiest way to obtain a count of items within an IEnumerable collection without enumerating over all of the items in the collection?

LINQ或Lambda可以使用吗?

Possible with LINQ or Lambda?

推荐答案

您将必须枚举计数.诸如List之类的其他结构仍在不断计数.

You will have to enumerate to get a count. Other constructs like the List keep a running count.

这篇关于获得IEnumerable< T>的最佳方法是使用IEnumerable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆