vinay khanna
What is differance between first and single in linq
By vinay khanna in .NET on Dec 15 2020
  • Yogeshkumar Hadiya
    Dec, 2020 30

    Single()

    1. Returns a single specific element of a query
    2. When Use: If exactly 1 element is expected; not 0 or more than 1. If the list is empty or has more than one element, it will throw an Exception “Sequence contains more than one element”

    First()

    1. Returns the first element of a query with multiple results.
      2. When Use: When 1 or more elements are expected and you want only the first. It will throw an exception if the list contains no elements.

    • 1
  • azat gumus
    Dec, 2020 18

    single throw an exception when query results more than a record but first results first item of a collection

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS