使用谓词.net 2.0 vb.net计算List(Of结构)中的项目 [英] count items in List(Of structure) using predicate .net 2.0 vb.net

查看:66
本文介绍了使用谓词.net 2.0 vb.net计算List(Of结构)中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在.net 2.0的列表中(结构列表)计算符合条件的项目.例如

Dim listcars as new list(or car)
Structure car
   Dim Name as string
   Dim year as integer
End structure


现在我需要计算所有名称为Toyota等的汽车,我该怎么做.
感谢

解决方案

这是您要查找的内容吗?

了解C#中的谓词委托 [ C#,List.Find()和谓词 [列表(T )成员(VB.NET) [ ^ ]

看看find和findall方法.


对所有提出建议和做出贡献的人表示感谢,

这是我找到的解决方案

 FoundCar = MyCars.FindAll(功能(项目 As  Car)项.名称= " ).计数


I need to count the items that meet a criteria in a list(of structure) in .net 2.0. eg

Dim listcars as new list(or car)
Structure car
   Dim Name as string
   Dim year as integer
End structure


Now i need to count all cars with name toyota etc, how do i do it.
thanks

解决方案

Is this what you''re looking for?

Understanding Predicate Delegates in C#[^]

C#, List.Find() and Predicates[^]

Hope it helps


List(T) members (VB.NET)[^]

look at the find and findall methods.


Thnaks for all who suggested and contributed,

Here is the solution i found

FoundCar = MyCars.FindAll(Function(item As Car) item.Name = "Toyota").Count


这篇关于使用谓词.net 2.0 vb.net计算List(Of结构)中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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