Lecture overview -- Keyboard shortcut: 'u'  Previous page: Upcasting and downcasting in C# -- Keyboard shortcut: 'p'    Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 40 : 40
Object-oriented Programming in C#
Specialization, Extension, and Inheritance
Inheritance and Variables

Variables (fields) are inherited

Variables cannot be virtual

  • A variable can be redefined in the sense:

    • Same name in super- and subclass: two entirely different meanings (new)

/user/normark/oop-csharp-1/sources/c-sharp/inheritance/variable-access/var-access.csAn illustration of "non-virtual variable access".


/user/normark/oop-csharp-1/sources/c-sharp/inheritance/variable-access/var-access-with-properties.csSimilar illustration with virtual properties.


/user/normark/oop-csharp-1/sources/c-sharp/inheritance/variable-access/exercise.csClasses for exercise.


Go to exerciseNon-virtual variables - Virtual Methods
We do not normally use public instance variables!