简体   繁体   中英

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.

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 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM