Upcasting

noun

say it: “UP-kast-ing” /ˈʌpkæstɪŋ/

Treating an object as its base class type, which is always safe and happens automatically.

What is Upcasting?

Upcasting is treating an object as its parent type. It is always safe, because a Dog is an Animal. It happens automatically.

Dog rex = new Dog();
Animal pet = rex; // upcast

In a sentence

  • “Putting an Ebook in a List<Book> is upcasting, and C# does it for you.”

Level: Journeyman · More OOP terms at this level

Updated