Whose Error Is It?

C# printed this

System.InvalidOperationException: Sequence contains no elements
What it meansA LINQ method like First, Single, Last, or Max was called on an empty sequence, so there was no element for it to return.
The first thing to checkCheck why the query returned nothing, then use FirstOrDefault or SingleOrDefault and handle null, or call Any() before calling First().

More from C#

All 75 errors

Whose Error Is It? · Status Menu · Back to the bar