Use of ArgumentNullException when accessing arguments' properties

前端 未结 1 961
渐次进展
渐次进展 2020-12-07 04:08

Suppose I have a class Foo with a complex property Bar. Then, suppose I have a method like the following in some other class:

publi         


        
相关标签:
1条回答
  • 2020-12-07 04:42

    Ideally, the Foo class would ensure that its Bar property is never null. If that's not possible, I would throw an ArgumentException in this case since the argument is not null, but it is invalid.

    0 讨论(0)
提交回复
热议问题