How can you call a method withou creating an instance ? (without Static)
How can you call a method withou creating an instance ? (without Static)
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.
VulpesPosted Apr 1, 2011, 8:32 AM
The keyword 'base' provides a reference to the base class instance and so all you're doing is obtaining a reference to a previously created object as I said before. In fact, you don't even need to use 'base' - you can just call WithoutStaticTest() directly as it's inherited by class2 and not hidden by a method of the same name.
If you didn't know already, the system provides every class which doesn't have a constructor with a default public parameterless constructor which does nothing but call the base class's parameterless constructor. In the case of an abstract class, the default constructor is protected rather than public.
An object is a bit like an onion with inner layers for the members contributed by each of its base classes and the outermost layer for the members which the object's class contributes.
Manikavelu VelayuthamPosted Apr 1, 2011, 8:12 AM
Its possible from derived classes using base keyword
VulpesPosted Apr 1, 2011, 5:28 AM