Class instance variable question

  • Thread starter Thread starter Janos
  • Start date Start date
J

Janos

Hi,

I am a newbie, learning C#. I try to map the concepts I have learned
earlier in other OO languages to the concepts used here in C# .

In Smalltalk you have class variable, which is here the static one,
existing only once, and the same for all instances of the class and
its sublasses.

But there you have also class instance variable, and the difference is
that the subclasses can override it. AFter that all the subclasses'
instances will use the overridden one, but the instances of the base
(super in Smalltalk) remains untouched.

Do we have here something similar as the class instance variable?

Thank you,
Janos
 
But there you have also class instance variable, and the difference is
that the subclasses can override it. AFter that all the subclasses'
instances will use the overridden one, but the instances of the base
(super in Smalltalk) remains untouched.

Do we have here something similar as the class instance variable?

Yes. the classes can provide their own instance variables but with a
different name (as against class/static variables).

The subclasses can have their own variables with the same name as in the
base class if and only if the ones in the base are private, ie, not visible
to the sub-class by any means.




--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
 
Janos said:
Hi,

I am a newbie, learning C#. I try to map the concepts I have learned
earlier in other OO languages to the concepts used here in C# .

In Smalltalk you have class variable, which is here the static one,
existing only once, and the same for all instances of the class and
its sublasses.

But there you have also class instance variable, and the difference is
that the subclasses can override it. AFter that all the subclasses'
instances will use the overridden one, but the instances of the base
(super in Smalltalk) remains untouched.

Do we have here something similar as the class instance variable?

Static properites can be written to give similar results.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top