That\'s kind of a general question (but I\'m using C#), what\'s the best way (best practice), do you return null or empty collection for a method that has a collection as a
I would argue that null
isn't the same thing as an empty collection and you should choose which one best represents what you're returning. In most cases null
is nothing (except in SQL). An empty collection is something, albeit an empty something.
If you have have to choose one or the other, I would say that you should tend towards an empty collection rather than null. But there are times when an empty collection isn't the same thing as a null value.