Quantcast
Viewing latest article 5
Browse Latest Browse All 6

Answer by Petar Minchev for What exception to throw when a property setter is not allowed?

Throw NotSupportedException exception.Quote from the link:

There are methods that are not supported in the base class, with the expectation that these methods will be implemented in the derived classes instead. The derived class might implement only a subset of the methods from the base class, and throw NotSupportedException for the unsupported methods.

My opinion is that InvalidOperationException is not a correct option.Quote from MSDN:

The exception that is thrown when a method call is invalid for the object's current state.

There is nothing about current state in your situation. It is that the class contract does not support the operation.


Viewing latest article 5
Browse Latest Browse All 6

Trending Articles