I have a Class MyClass that have a method MyFunction which return a Boolean. then I have a array MyArray of MyClass and I need to return true if this array have a object where MyFunction returns true, i actually use this:
bool MyOtherFunction () {
foreach (MyClass x in MyArray.Where(y => y.MyFunction))
{
return true;
}
return false;
}
But Visual Studio keeps warning me because "Local variable 'x' is never used", So, how can I check this without declaring a new variable?
ifrather than aforeachloop?