Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between NotSupportedException and NotImplementedException?

Tags:

c#

.net

exception

My classes that implements an interface, I've got to throw an exception if the class doesn't support values from parent class (done by setting the get property to false/true), so why should I use NotSupportedException, but not NotImplementedException?

When should I use NotImplementedException then? learn.microsoft.com say that it's always better to use NotSupportedException, is it true?

I've found sth like that: https://blog.excastle.com/2004/10/15/notimplementedexception-vs-notsupportedexception/, but it was written in 2004, I think many changed after that. Also, it is written in quite complicated way.

like image 891
Arekadiusz Avatar asked Dec 28 '21 15:12

Arekadiusz


People also ask

What is NotImplementedException?

The NotImplementedException exception indicates that the method or property that you are attempting to invoke has no implementation and therefore provides no functionality. As a result, you should not handle this error in a try/catch block. Instead, you should remove the member invocation from your code.

What is System NotSupportedException?

NotSupportedException indicates that no implementation exists for an invoked method or property.

What are notimplementedexception and platformnotsupportedexception?

The .NET Framework also includes two other exception types, NotSupportedException and PlatformNotSupportedException, that indicate that no implementation exists for a particular member of a type. You should throw one of these instead of a NotImplementedException exception under the following conditions.

What does the notsupportedexception mean?

The NotSupportedException exception indicates that a method has no implementation and that you should not call it. You should not handle the exception.

What is notimplementedexception in Java?

The NotImplementedException is a way of declaring that a particular method of an interface or base class is simply not implemented in your type. This is the exception form of the E_NOTIMPL error code.

What does throw new notimplementedexception mean?

Throw New NotImplementedException() End Sub Remarks. The NotImplementedException exception is thrown when a particular method, get accessor, or set accessor is present as a member of a type but is not implemented. NotImplementedException uses the default Object.Equals implementation, which supports


Video Answer


1 Answers

"Not Implemented" implies that it could be implemented it in the future. "Not Supported" makes no such implication as to whether you may implement it or if it even can be implemented.

NotImplementedException is generally used during development as a way to flag to yourself (or Testers, or any other developers) that some aspect hasn't been implemented yet but it is intended to be implemented. You wouldn't normally include this exception in a formal release.

like image 169
RBarryYoung Avatar answered Oct 29 '22 02:10

RBarryYoung