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.

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