give me an example of a constructor in c#
Example: give me an example of a constructor in c#
// Prog.cs
class Program
{
stataic void Main(string[] args)
{
Car Ford = new Car("Mustang", "Red", 1969);
Car Opel = new Car("Mustang", "Red", 1969);
Console.WriteLine(Ford.model);
Console.WriteLine(Opel.model);
}
// Prog2.cs
class Car
{
public stirng model;
public string color;
public int year;
public Car(string ModelName, ModelColor, ModelYear)
{
model = ModelName;
color = ModleColor;
year = ModelYear;
}
}