[ACCEPTED]-Using List.Exists and Predicates correctly-vb.net
Accepted answer
List(Of T).Contains
is the method you should be using. Exists, as 7 you say, expects a predicate. Of course, for 6 .Contains to work as expected, you need 5 to override the Equals()
method, as well as GetHashCode()
.
List(Of T).Exists
expects 4 a function that will return a Boolean value 3 when passed an item of type T, where T, in 2 your case, is of type Stuff. So, you could 1 write a method that looks like:
If Not l_stuff.Exists(Function(x) x.property1 = m_stuff.property1 And _
x.property2 = m_stuff.property2) Then
and so on.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.