且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取列表的项目数.使用Linq

更新时间:2023-01-24 10:31:05

 var numSpecialBooks = StoreDisplayTypeList.Count(n => n.DisplayType == "Special Book");

这使用了 Enumerable.Count 的重载,该重载需要一个Func<TSource, bool>谓词可过滤序列.

This uses an overload of Enumerable.Count that takes aFunc<TSource, bool>predicate to filter the sequence.