Where to check if an object is null or not?

前端 未结 13 1493
广开言路
广开言路 2020-12-17 10:18

Where do you check if an object that you are passing to a method is null or not?

Should an object need to be tested before calling a method? or within the method tha

13条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-17 11:07

    I would say that checking it n PrintAge seemed to make more sense as that is fulfiling the contract for the routine. You could, of course, replace the null checks with Debug.Assert() code to check at test time, but not at release time.

提交回复
热议问题