NotSupportedException

When you do not want to implement a method at all, throw NotSupportedException in its body; do not throw NotImplementedException.

For example if you want to define a Converter that, by design, would only need to support one way bindings for WPF, implementing only Convert method of IValueConverter or IMultiValueConverter interface, throw NotSupportedException instead of NotImplementedException in ConvertBack, even without an error message (since the message is to the client developer):

public object ConvertBack(object value, …)
{
  throw new NotSupportedException();
}

Throwing NotSupportedException clearly indicates your intention, while throwing NotImplementedException might wrongly indicate that the code is not yet complete and that this would eventually change.

Advertisements

About Sorin Dolha

My passion is software development, but I also like physics.
This entry was posted in .NET, C#, WPF and tagged , . Bookmark the permalink.

Add a reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s