when working with the List class, i have noticed that the boolean i was looking for was:
if(lstInts.Exists(x)){...}
X is a Predicate of T the same as lstInts. I was confused as to why you just cant pass int the int in this case, and why X’s type isnt of type T.
Example i was testing:
List<int> listInt = new List<int>();
int akey = Convert.toInt32(myMatch.Value);
Predicate<int> pre = new Predicate<int>(akey); //akey is not the correct constructor param.
if(listInt.Exists(pre)){
listInt.add(akey);
}
Is there a reason for having the additional Step of Predicate, or…. if i am going about the logic incorrectly?
I also noticed that the predicate constructure does not take an item of type T. Sort of confused as to how this is suppose to work.
You could also use Contains() method
Or alternately use Any()