In C#, are there any built-in exceptions I shouldn't use?

前端 未结 6 2917
[愿得一人]
[愿得一人] 2021-02-20 10:08

Are there any Exceptions defined in the .NET Framework that I shouldn\'t throw in my own code, or that it is bad practice to? Should I write my own?

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-20 10:38

    @Michael There is actually one situation in which it is recommended to throw a NullReferenceException: If the first parameter (the "this" parameter) of an extension method is null. You need to do this in order that null variables behave as expected.

提交回复
热议问题