i have the following code in C#:
if (this.Trucks.Any() || this.Cars.Any())
{
return true;
}
return false;
but i just realized that sometimes one or either of these arrays is null so in my case i wan null to just return false (instead of throwing exception).
I could add upfront null checks like this:
if ((this.Trucks != null && this.Trucks.Any()) ||
(this.Cars != null && this.Cars.Any()))
{
return true;
}
return false;
}
but wanted to see if there was a cleaner way