Skip to content

PRO TIP Block youtube.com at the DNS level โ€” Pi-hole, NextDNS or your hosts file โ€” but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

C# objects as arguments ๐Ÿงณ

30.3K views on YouTube

C# passing objects as arguments tutorial example explained

#C# #objects #arguments

using System;

namespace MyFirstProgram
{
class Program
{
static void Main(string[] args) {

Car car1 = new Car(“Mustang”,”red”);

Car car2 = Copy(car1);

Console.WriteLine(car2.color + ” ” + car2.model);

Console.ReadKey();
}

public static void ChangeColor(Car car, String color)
{
car.color = color;
}

public static Car Copy(Car car)
{
return new Car(car.model, car.color);
}
}
class Car
{
public String model;
public String color;

public Car(String model, String color)
{
this.model = model;
this.color = color;
}
}
}