Local variable is never used warning for foreach loop

c#, linq

Solution

It appears that what you want to do is execute some code if there are any items in that query, rather than executing those lines of code for every item in the query. The `Any` method allows you to do this more effectively:

if(temp.Any(refKey => this.Teachers.License_key == refKey.ReferenceKey))
{
    someBool = true;
    this.NotifyPropertyChanged("SomeProperty");
}

Problem

I have written something like this below, `Resharper` says Local variable `refKey` is never used. How Can I make this written a little nicer? ``` var temp = this.SomeCollection.ToList(); foreach (var refKey in temp.Where(refKey => this.Teachers.License_key == refKey.ReferenceKey)) { someBool = true; this.NotifyPropertyChanged("SomeProperty"); } ```

Original source