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 🧍‍♂️

94.5K views on YouTube

C# object oriented programming tutorial example explained

#C# #objects #classes

using System;

namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
// object = An instance of a class
// A class can be used as a blueprint to create objects (OOP)
// objects can have fields & methods (characteristics & actions)

Human human1 = new Human();
Human human2 = new Human();

human1.name = “Rick”;
human1.age = 65;

human2.name = “Morty”;
human2.age = 16;

human1.Eat();
human1.Sleep();

human2.Eat();
human2.Sleep();

Console.ReadKey();
}
}
class Human
{
public String name;
public int age;

public void Eat()
{
Console.WriteLine(name + ” is eating”);
}
public void Sleep()
{
Console.WriteLine(name + ” is sleeping”);
}
}
}