Throwing ArgumentNullException in constructor?

前端 未结 4 1716
眼角桃花
眼角桃花 2020-12-08 02:34

For a constructor with a single parameter, is it OK to throw an ArgumentNullException inside the constructor if the parameter is null/empty? OR, should it be thrown in the m

4条回答
  •  无人及你
    2020-12-08 02:52

    Throwing it in the constructor is fine - there are several classes in the .NET framework that do this. Additionally, check out code contracts for this.

提交回复
热议问题