how to check if a list is empty c# code example
Example 1: how to check if a list is empty java
if (list != null && !list.isEmpty()) { do something }
Example 2: c# tell if list object is empty
if(listOfObjects.Count == 0){
//when list is empty
}
Example 3: how to check a list is null or empty in c#
if ( (myList!= null) && (!myList.Any()) )
{
// Add new item
myList.Add("new item");
}
Example 4: check if list contains any empty element in c#
if (myList.Any(i => i != null))
{
DoSomeThing();
}