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

前端 未结 5 566
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:40

    NotImplementedException is simply an exception that is used when the code for what you're trying to do isn't written yet. It's often used in snippets as a placeholder until you fill in the body of whatever has been generated with actual code.

    It's good practice to use a NotImplementedException as opposed to an empty block of code, because it will very clearly throw an error alerting you that section of your code isn't complete yet. If it was blank, then the method might run and nothing would happen, and that's a pain to debug sometimes.

提交回复
热议问题