ArgumentException vs. ArgumentNullException?

前端 未结 4 1100
予麋鹿
予麋鹿 2021-01-03 20:13

I’m refactoring some code and adding a method which will replace a (soon-to-be) deprecated method. The new method has the following signature:

FooResult Foo         


        
4条回答
  •  清歌不尽
    2021-01-03 21:12

    While I agree completely with dasblinkenlight's answer, you may also want to consider moving the validation for FooArgs into the FooArgs class itself. If this class is designed specifically to move arguments around, it is likely not valid for it to have null proeprties, in which case, I would allow it's constructor to do it's validation.

提交回复
热议问题