What exceptions should be thrown for invalid or unexpected parameters in .NET?

后端 未结 7 749
误落风尘
误落风尘 2020-12-22 16:43

What types of exceptions should be thrown for invalid or unexpected parameters in .NET? When would I choose one instead of another?

Follow-up:

Which excep

7条回答
  •  庸人自扰
    2020-12-22 17:08

    There is a standard ArgumentException that you could use, or you could subclass and make your own. There are several specific ArgumentException classes:

    http://msdn.microsoft.com/en-us/library/system.argumentexception(VS.71).aspx

    Whichever one works best.

提交回复
热议问题