Rather than checking for null, check count, as the rule of thumb is not to return null but an empty list, in this case.
For example, depending on the day of the week, return a list of two items or an empty list. The code was written with NET Core 9.
internal static class DateTimeExtensions
{
public static bool IsWeekend(this DateTime self)
=> self.DayOfWeek is DayOfWeek.Sunday or DayOfWeek.Saturday;
}
.
.
.
private static List<string> GetList()
=> DateTime.Now.IsWeekend() ? ["item 1", "item 2"] : [];
.
.
.
List<string> list = GetList();
if (list.Count == 0)
{
// Handle the case where the list is empty
}