NotImplementedException
A C# NotImplementedException
has been thrown. An exception's type helps us learn the reason the exception was thrown.
The NotImplementedException
indicates in a clear way that the functionality being requested was simply not implemented.
The NotImplementedException
should not be thrown in completed programs. When adding a method, you may want the method to exist but you may not be able to implement it yet.
NotImplementedException
in an unimplemented method.NotImplementedException
prevents this from happening and so keeps the program compiling.using System; class Program { static void Main() { Method(); } static int Method() { // Leave this as a stub. throw new NotImplementedException(); } }Unhandled exception. System.NotImplementedException: The method or operation is not implemented. at Program.Method() in /home/sam/programs/consoletemp/Program.cs:line 13 at Program.Main() in /home/sam/programs/consoletemp/Program.cs:line 7 Aborted (core dumped)
When using exceptions, you want to describe the problem as much as possible through the type itself. In error messages, the type of the exception is prominently featured.
NotImplementedException
occurs, you will realize that the problem is unfinished code—not another error.As a descriptive exception type, the NotImplementedException
is useful as a way to compile an unfinished program. Visual Studio inserts it in method stubs.