A less-efficient answer:
if(myList.Count == 0){
// nothing is there. Add here
}
Basically new List<T>
will not be null
but will have no elements. As is noted in the comments, the above will throw an exception if the list is uninstantiated. But as for the snippet in the question, where it is instantiated, the above will work just fine.
If you need to check for null, then it would be:
if(myList != null && myList.Count == 0){
// The list is empty. Add something here
}
Even better would be to use !myList.Any()
and as is mentioned in the aforementioned L-Four's answer as short circuiting is faster than linear counting of the elements in the list.