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?
CodePudding user response:
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.