Junior OOP

What is a constructor?

  • A special method used to initialize objects when they are created.
  • Has the same name as the class and no return type.

public class Car

public string Model;

public Car(string model) { Model = model; }

Car car = new Car("Tesla");

More from C# Programming Tutorial

All questions for this course