I have a class property that is a list of strings, List. Sometimes this property is null, or if it is set, but the list is empty, then count is 0. However, in another place in my code I need to check if this property is set, so currently my code checks if it is null and it is considered 0, which seems messy.
if(objectA.folders is null)
{
if(objectA.folders.count == 0)
{
// do something
}
}
Any recommendation on how this should be handled? Maybe I should always initialize the property so that it is never null?
source
share