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"); }
}Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png