Class NotImplementedByException
- Namespace
- Gamelogic.Extensions
- Assembly
- Assembly-CSharp.dll
A version of NotImplementedException that takes the throwing type as argument. This is useful in class hierarchies where methods are meant to be overridden by derived types but cannot be made abstract (for example, because of Unity limitations). The exception, when thrown, indicates which class should have implemented the method, but hasn't.
public class NotImplementedByException : NotImplementedException, _Exception, ISerializable
- Inheritance
-
NotImplementedByException
- Implements
- Inherited Members
- Extension Methods
Examples
In the following example, the derived class does not override the method Method. When Method is called on an instance of DerivedClass, a NotImplementedBy exception will be thrown with DerivedType as parameter, making it easy to see DerivedClass needs to implement Method.
<pre><code class="lang-csharp">[Abstract]
public class BaseClass
{
[Abstract]
public virtual void Method()
{
throw new NotImplementedBy(GetType());
}
}
public class DerivedClass : BaseClass { }</code></pre>
Remarks
This is a develop-time exception, and should generally not be caught.
Constructors
NotImplementedByException(Type)
Initializes a new instance of the NotImplementedByException class.
public NotImplementedByException(Type type)
Parameters
type
TypeThe type of the class that throws this exception.