按列表中的类型获取计数

Get the count by type in a List

我无法按类型获取计数。

我如何获得首页 (PartnerIntegrationbTesting.Context.Home) 的计数?列表中有 4 项 (quoteList.Products)

使用.Count()过滤功能。 is 将测试 left-hand 对象是否为右侧指定的类型。

var countOfHomeProducts = quoteList.Products
   .Count(p => p is PartnerIntegrationbTesting.Context.Home);