list will never be null with LINQ; it will simply represent an “empty collection” if need be. The way to test is with the Any extension method:
if (list.Any()) {
// list has at least one item
}
list will never be null with LINQ; it will simply represent an “empty collection” if need be. The way to test is with the Any extension method:
if (list.Any()) {
// list has at least one item
}