C# Exception Specs

Why doesn’t C# have exception specifications?

Some languages allow or require member signatures to include exception specifications. For example, in a language with such a construct, a method that raises an ArgumentException can be declared with:

void DoSomething(int a) throws ArgumentException {…}

C# neither requires nor allows such exception specifications. There are a number of reasons for this omission, namely:


Productivity and code quality

Impracticality of having class author differentiate between “checked” and “unchecked” exceptions

Difficulty of determining the correct exceptions for interfaces.

Leave a Reply

Your email address will not be published. Required fields are marked *