Is it better to return null or empty collection?

前端 未结 18 1935
我在风中等你
我在风中等你 2020-11-22 07:56

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

18条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 08:33

    We had this discussion among the development team at work a week or so ago, and we almost unanimously went for empty collection. One person wanted to return null for the same reason Mike specified above.

提交回复
热议问题