First and FirstOrDefault Methods
Learn how to choose one element from a collection using First and FirstOrDefault methods.
We'll cover the following...
We'll cover the following...
How to pick the first element of a collection
The First and FirstOrDefault methods return the first element in a collection. The First method throws an exception if the collection is empty. Unlike First, FirstOrDefault returns a default value if the collection is empty.
Also, First and FirstOrDefault return the first ...