first vs firstordefault in linq

  •  What is the difference between first and firstOrDefault in Linq?
  1. First() method return first element from list and if element is empty it's throw exception.
  2. firstOrDefault () will handle exception if list contain no element.

Comments