Lecture overview -- Keyboard shortcut: 'u'  Previous page: Upcasting and downcasting in C# -- Keyboard shortcut: 'p'  Next page: Inheritance and Variables -- Keyboard shortcut: 'n'  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 39 : 40
Object-oriented Programming in C#
Specialization, Extension, and Inheritance
Upcasting and downcasting in C#

Upcasting and downcasting reflect different views on a given object

The object is not 'physically changed' due to upcasting or downcasting

  • Upcasting:

    • Can occur implicitly during assignment and parameter passing

    • A natural consequence of polymorphism and the is-a relation

    • Can always take place

  • Downcasting:

    • Must be done explicitly by use of type casting

    • Can not always take place