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

前端 未结 5 563
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:31

    Think about this: what if you want to add two integers with the following method...

    private int Add(int x, int y)
    {
    
    }
    

    ...and have no code inside to do such (the method doesn't even return an integer). This is what NotImplementedException is used for.

提交回复
热议问题