Is this a good practice?:
IMO, its better to throw NotImplementedException
since what else would you return, if you return null
, the user of your class would never know that this method has to be overridden. So I would disagree with your boss.
this seems like a good place to have an abstract method in a nonabstract class. Why is this not allowed?
You may see the discussion: Abstract Method in Non Abstract Class
I have a class that is a base for some other classes. The class has a virtual method, which is supposed to be overridden in the derived classes.
Why not define the method as abstract
instead of virtual.
Use the abstract modifier in a method or property declaration to indicate that the method or property does not contain implementation.
BUT
- An abstract method is implicitly a virtual method.
- Abstract method declarations are only permitted in abstract classes.
- Because an abstract method declaration provides no actual implementation, there is no method body; the method declaration
simply ends with a semicolon and there are no curly braces ({ })
following the signature.