c# - Best way to check if any value exists on ArrayList -
i have arraylist
. want check if value exits in t arraylist
. use method (from system.linq
namespace), can use on array
, not arraylist
.
is there efficient way check this?
well, check .count > 0
. better option stop using arraylist
. since know any()
, system.linq
, assume you're not using .net 1.1; use list<t>
t
, , problems solved. has full linq-to-objects usage, , better idea.
list<int> myints = ... bool anyatall = myints.any(); bool anyevens = myints.any(x => (x % 2) == 0); // etc