Monday, October 17, 2016

.SingleOrDefault

...in LINQ is a lot like .FirstOrDefault. If you are familiar with .FirstOrDefault you can probably guess what .SingleOrDefault does, huh?

  1. It will return the default value for the type if there are no matches.
  2. It will return what it finds if there is one match.
  3. It will throw an exception if there is more than one match.

No comments:

Post a Comment