static classes
Can we inherit static classes or not?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vishal VermaPosted Aug 24, 2015, 8:13 AM
Sumit JoshiPosted Aug 24, 2015, 7:13 AM
Upendra Pratap ShahiPosted Aug 24, 2015, 7:11 AM
Inheritance in .NET works only on instance base. Static methods are defined on the type level not on the instance level. That is why overriding doesn't work with static methods/properties/events...
Static methods are only held once in memory. There is no virtual table etc. that is created for them.
If you invoke an instance method in .NET, you always give it the current instance. This is hidden by the .NET runtime, but it happens. Each instance method has as first argument a pointer (reference) to the object that the method is run on. This doesn't happen with static methods(as they are defined on type level). How should the compiler decide to select the method to invoke?