You can use Enumerable.Any
:
bool isEmpty = !list.Any();
if(isEmpty)
{
// ...
}
If the list could be null
you could use:
bool isNullOrEmpty = list?.Any() != true;
More Related Contents:
- How to split Fromdate and Todate based on weekdays(Sat,Sun) using linq c#
- How do I clone a generic list in C#?
- IEnumerable vs List – What to Use? How do they work?
- Remove duplicates from a List in C#
- Check whether an array is a subset of another
- How create a new deep copy (clone) of a List?
- Remove items from one list in another
- A method to count occurrences in a list
- Select distinct using linq [duplicate]
- Inheriting from List
- ICollection Vs List in Entity Framework
- Check if a string contains an element from a list (of strings)
- Getting unique items from a list [duplicate]
- Fast way to convert a two dimensional array to a List ( one dimensional )
- Differences between IQueryable, List, IEnumerator?
- How to remove item from list in C#?
- Class List Keeps Printing Out As Class Name In Console?
- Are 2 dimensional Lists possible in c#?
- Create list of variable type
- Check if all items are the same in a List
- How do I get a list of installed updates and hotfixes?
- C#: How to add subitems in ListView
- How do I check if a given value is a generic list?
- Select distinct by two properties in a list
- Count property vs Count() method?
- Using Linq Except not Working as I Thought
- How to Quickly Remove Items From a List
- List.Except is not working
- What is the best way to check two List lists for equality in C#
- Eliminate consecutive duplicates of list elements