Constructor
A special method that runs when an object is created and sets its starting values.
What is Constructor?
A constructor is a special method that runs when a new object is created. It sets the object up with its starting values.
public class Player
{
public string Name { get; }
public int Score { get; private set; }
public Player(string name)
{
Name = name;
Score = 0;
}
}
Level: Novice · More OOP terms at this level
Updated