TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

C# NotImplementedException

This C# exception article demonstrates NotImplementedException.

NotImplementedException. A 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.

Example. To start, the NotImplementedException is not a debugging construct, but it 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.

And: This can help with a complex system as it is developed. This example uses NotImplementedException in an unimplemented method.

C# program that uses NotImplementedException

using System;

class Program
{
    static void Main()
    {
	Method();
    }

    static int Method()
    {
	// Leave this as a stub.
	throw new NotImplementedException();
    }
}

Results
    Exception message is printed to screen.

In the example, please notice how the method returns an integer value. A compile-time error would occur if the method simply had a blank body. The NotImplementedException prevents this from happening and so keeps the program compilable.

Self-documenting type. 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.

Therefore: When the NotImplementedException occurs, you will realize that the problem is unfinished code—not another error.

Summary. Through specific exception types, you can accurately describe the problems that occur in your program. As a descriptive exception type, the NotImplementedException is useful as a way to compile an unfinished program.

Finally: Visual Studio inserts the NotImplementedException in method stubs such as in Windows Forms programs. It is a convention.


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf