[英]Loop through a complex list using linq in VB.net
I have a field called LotNo and a List(Of LotDTO) called LotsList that has among other properties a LotNumber() property both of type string.我有一个名为 LotNo 的字段和一个名为LotsList的 List(Of LotDTO ),它在其他属性中有一个 LotNumber() 属性,两者都是字符串类型。
This if statement is not working If (LotsList.Contains(selectedLot.LotNo) Then …
because I am obviously comparing a complex object to a string so what is the correct way?这个 if 语句不起作用
If (LotsList.Contains(selectedLot.LotNo) Then …
因为我显然是在将一个复杂的 object 与一个字符串进行比较,那么正确的方法是什么?
If LotsList.Any(Function(lot) lot.LotNo = selectedLot.LotNo) Then
The Any
extension method will tell whether any items in a list satisfy an arbitrary Boolean condition. Any
扩展方法将判断列表中的任何项目是否满足任意 Boolean 条件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.