Static classes
Can we inherit static classes or not?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 24, 2015, 3:11 AM EDT
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?
Sumit JoshiRank #1,252 · 1.4K reputationPosted Aug 24, 2015, 3:13 AM EDT
Vishal VermaRank #2,024 · 715 reputationPosted Aug 24, 2015, 4:13 AM EDT