Enumerable.defaultIfEmpty Method
Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty.
This method is static.
Parameters
- source
-
Type: IEnumerable
The sequence to return if not empty.
- defaultValue
-
Type: Object
The value to return if source is empty.
Return Value
Type: IEnumerable
An enumerable that contains defaultValue if source is empty; otherwise, the sequence from source.