C# objects 🧍‍♂️

preview_player
Показать описание
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.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");
}
}
}
Рекомендации по теме
Комментарии
Автор

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");
}
}
}

BroCodez
Автор

Omg you're awesome! I struggled with OOP for 2 weeks in class and you just made this so simple. Thank you!

ino
Автор

Awesome stuff! I’m learning C# through a book called C# players guide. It’s a very good book but your content is really solidifying some of the complex key terms

aarongarcia
Автор

@Bro, Your Teaching skills and the examples you use are phenomenal. I've learned from nothing to something, All thanks to these tutorials.

stapelton
Автор

Great video! Very easy to grasp and is easy to understand the concepts of a class. Appreciate this!

abraham.hayden
Автор

Nice video bro!! you help to understand in a good way how objects works!!

victorh.lopezchavez
Автор

My teacher just send our class a 30 minutes video and your videos just saved me 20 minutes. Well deserved for a new subscriber

rafinoor
Автор

Perfect. Very well explained with a good example.

andrehufschmid
Автор

Bro you are the best im trying to understand what is object for hours and you just made it clear, thak you so much!

osplace
Автор

Bro are awesome. Been trying to figure OOP thinking it's rocket science but you have made it where even I can understand it. Actually I got a degree in rocket science but that doesn't make me a rocket scientist.

willlywillly
Автор

If I let coding make me nervous, then I can’t get schwifty

marajohnson
Автор

Evereyone's first project: "Hello world"

My first project: Creating a human being from scratch

alexandregb
Автор

can you create tutorial vids like this using WinUI 2 or 3 UI frameworks?

pantsutsama
Автор

Thanks for the tutorial, but is there a faster/more intuitive way to define an object with all of its properties? It seems like defining many objects with many different properties would be very time consuming. I'm more familiar with Python, where it's as easy as calling the class with all of the desired values for the properties.

katawaya
Автор

Normally I put a random comment down below but why is it considered insecure to make them public? what would be the preferred solution?

the_dude_josh