What is the difference between Single() and First() extension methods in LINQ?
Single() | First() |
---|---|
Used to return a single specific element of a query or a default value if no result is found. | It is used to return the first element of any query with multiple values. |
Used when exactly one element is expected as a result. | Used when there are multiple result expectations but you only need the first value. |
BY Best Interview Question ON 15 Apr 2020