What does “throw new NotImplementedException();” do exactly?

前端 未结 5 565
Happy的楠姐
Happy的楠姐 2021-01-23 06:01

I have a class \'b\' that inherits from class \'a\'. In class \'a\' there is some code that performs an action if an event is not null. I need that code to fire in class \'b\'

5条回答
  •  借酒劲吻你
    2021-01-23 06:33

    The NotImplementedException is a way of declaring that a particular method of an interface or base class is simply not implemented in your type. This is the exception form of the E_NOTIMPL error code.

    In general an implementation shouldn't be throwing a NotImplementedException unless it's a specifically supported scenario for that particular interface. In the vast majority of scenarios this is not the case and types should fully implement interfaces.

    In terms of what it's doing though. It's simply throwing an exception. It's hard to say why the program keeps function in the face of the exception and breaks without it unless you give us a bit more information.

提交回复
热议问题