C Sharp (C#) - LINQ Fundamentals
Which method should you use if you want to get a single element from a collection and ensure there is exactly one match?
Which method should you use if you want to get a single element from a collection and ensure there is exactly one match?
Single() method returns the only element of a collection and throws an exception if there is not exactly one element.First() returns the first element regardless of how many exist, FirstOrDefault() returns first or default, and Last() returns the last element.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions