Javatpoint Logo
Javatpoint Logo

LINQ DefaultfEmpty() Method

In LINQ, DefaultfEmpty() method is used to return the default value in that case if the list/collection contains the null or empty value; otherwise, it will return the element from the sequence in the collection.

Syntax of using the LINQ DefaultfEmpty() method to get the list of the elements when the list returns an empty or null value.

From the above syntax, we are getting the list of items using the LINQ DefaultfEmpty method.

Example of LINQ DefaultfEmpty() Method

Here is the example of the LINQ DefaultfEmpty() method to get the elements from the list or return the value when we not found any element in the list/collection.

In the above example, we have two lists a and b, and we are trying to get the elements from these two lists using LINQ DefaultfEmpty() method.

Output:

LINQ DefaultfEmpty() Method





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA