Junior From PDF OOP C# OOP

What is the : base() keyword used for?

  • Calls the constructor of the base class from a derived class.
  • Ensures base class initialization before derived class constructor runs.
class Vehicle { public Vehicle(string brand) {

Console.WriteLine(brand); } }

class Car : Vehicle
{
public Car(string brand) : base(brand) { Console.WriteLine("Car

created"); }

}

More from C# Programming Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details