Re: List<>.Exists()???



What you are looking for is List<T>.Contains(...), i.e.

if(!numList.Contains(newNumber)) {...}

That should fix it; for completeness:
List<T>.Exists(...) checks whether any of the items in the list
satisfies a condition (specified as a predicate); for example, to test
whether any of the numbers are divisible by 3 (using the new C# 3
"lambda" syntax):

if (numList.Exists(i => i % 3 == 0)) {...}

The "predicate" is just a method that accepts the item to be tested
and returns true (match) or false:

static bool SomeMethod(int i) {
return i % 3 == 0;
}
....
if (numList.Exists(SomeMethod)) {...}

Does that make it any clearer?

Marc


.



Relevant Pages

  • Re: List<>.Exists()???
    ... I think it may have something to do with the fact that the help article for ... That should fix it; for completeness: ... a condition (specified as a predicate); for example, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Pthread programming: about the lost condition signals.
    ... If a thread makes the predicate true and it's supposed to be false, ... signals to get the appropriate A or B thread to fix the problem. ... or use broadcasts. ...
    (comp.programming.threads)
  • Re: Couldnt log into Windows Server because of a virus
    ... (OP's response written below signature delimiter and stripped; here it is for completeness): ... Thank you very much for your advice. ... I'm glad you were able to fix this. ...
    (microsoft.public.security.virus)
  • Re: Return only most recent date records
    ... Can you explain the predicate 'TOP 1*'? ... > PerL ... so I don't know what to fix. ...
    (microsoft.public.access.queries)
  • copy_term/2 in Eclipse
    ... I want to use the copy_term/2 predicate in order to generate the copy of ... the orginial term. ... Does anyone have an idea of how to fix this (or what ... Any hint would be welcome. ...
    (comp.lang.prolog)