C# inheritance

C# inheritance

Bro Code

3 года назад

52,699 Просмотров

C# inheritance tutorial example explained

#C# #inheritance #tutorial

using System;

namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
// inheritance = 1 or more child classes recieving fields, methods, etc. from a common parent

Car car = new Car();
Bicycle bicycle = new Bicycle();
Boat boat = new Boat();

Console.WriteLine(car.speed);
Console.WriteLine(car.wheels);
car.go();

Console.WriteLine(bicycle.speed);
Console.WriteLine(bicycle.wheels);
bicycle.go();

Console.WriteLine(boat.speed);
Console.WriteLine(boat.wheels);
boat.go();

Console.ReadKey();
}
}
class Vehicle
{
public int speed = 0;

public void go()
{
Console.WriteLine("This vehicle is moving!");
}
}
class Car : Vehicle
{
public int wheels = 4;
}
class Bicycle : Vehicle
{
public int wheels = 2;
}
class Boat : Vehicle
{
public int wheels = 0;
}
}

Тэги:

#unity #unity3d #tutorial #beginner #easy #function #and #settings #how #to #howto #learn #learning #course #series #tips #tricks #tutorials #workflow #fix #tip #technology #game #development #develop #games #programming #coding #basic #basics #C# #inheritance #derive #deriviation #base #class #classes #value #properties #fields #Unity_(Software) #Computer_Program_(Literature_Subject)
Ссылки и html тэги не поддерживаются


Комментарии:

Bro Code
Bro Code - 20.06.2021 16:50

using System;

namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
// inheritance = 1 or more child classes recieving fields, methods, etc. from a common parent

Car car = new Car();
Bicycle bicycle = new Bicycle();
Boat boat = new Boat();

Console.WriteLine(car.speed);
Console.WriteLine(car.wheels);
car.go();

Console.WriteLine(bicycle.speed);
Console.WriteLine(bicycle.wheels);
bicycle.go();

Console.WriteLine(boat.speed);
Console.WriteLine(boat.wheels);
boat.go();

Console.ReadKey();
}
}
class Vehicle
{
public int speed = 0;

public void go()
{
Console.WriteLine("This vehicle is moving!");
}
}
class Car : Vehicle
{
public int wheels = 4;
}
class Bicycle : Vehicle
{
public int wheels = 2;
}
class Boat : Vehicle
{
public int wheels = 0;
}
}

Ответить
oMirrorxFc
oMirrorxFc - 06.11.2023 04:35

bro code's unique weakness is spelling

Ответить
Sadık Gel
Sadık Gel - 06.10.2023 23:43

hocam KRALSIN

Ответить
MrEastgalaxy
MrEastgalaxy - 09.09.2023 10:38

BRO!

Ответить
anxiouscunt
anxiouscunt - 07.09.2023 16:05

you didnt explain base keyword..

Ответить
ye
ye - 29.08.2023 19:02

This is definitely Chad activity here. This needs to to studied.

Ответить
MahrezLol
MahrezLol - 26.08.2023 21:47

nice!

Ответить
Danny White
Danny White - 13.08.2023 22:24

good video amogus

Ответить
John G
John G - 25.07.2023 14:59

woot woot!

Ответить
Mina Edward
Mina Edward - 24.06.2023 07:46

How can you write Console .writeline when you write cw

Ответить
Mat Izi
Mat Izi - 04.06.2023 17:05

Please add an explanation on how constructors work in inheritance

Ответить
Tupll
Tupll - 21.05.2023 14:06

Bro you explain stuff in 4 min so i get it i its crazy pls keep doing these videos

Ответить
Moses Kawli
Moses Kawli - 09.05.2023 08:45

Well explain inheritance. Love it.

Ответить
zdspider
zdspider - 07.05.2023 14:05

Aren't you supposed to mark the functions you want to override as "virtual"?
Or is that just a C++ thing and not present in C#?

Ответить
Avinash Parab
Avinash Parab - 20.04.2023 10:28

Your knowledge and the way you are explaining it.. It's an amazing❤

Ответить
K Madhavi
K Madhavi - 11.03.2023 17:28

Amazing video sir 🤗

Ответить
Sk Hasan Al Sahib
Sk Hasan Al Sahib - 27.01.2023 06:12

I find your videos to be very helpful. Thanks a lot, I really appreciate it!

Ответить
EMMANUEL MIAKO
EMMANUEL MIAKO - 20.01.2023 08:54

I like it, Picasso!

Ответить
Umut Kilexter
Umut Kilexter - 28.12.2022 02:23

teşekkür ederim

Ответить
BUDDERRAR
BUDDERRAR - 25.12.2022 23:11

noice

Ответить
munupixi
munupixi - 27.11.2022 13:06

и ну да

Ответить
Millequattro
Millequattro - 05.11.2022 16:26

I LOVE your 4 minutes videos, your channel is totally underrated

Ответить
Noluthando Zama
Noluthando Zama - 13.10.2022 01:53

absolutely amazing thank you I needed this.

Ответить
The 3D Cookie
The 3D Cookie - 10.10.2022 10:56

Thanks bro

Ответить
mσǝ
mσǝ - 05.10.2022 21:20

Great explainations!
i see few do like this:
Vehicle boat = new boat();

and not like you do:
Boat boat = new boat();

why use

parentclass v = new childclass();

or

childclass v = new childclass();

Ответить
kartakartak
kartakartak - 04.10.2022 12:22

Very well explained!

Ответить
מלכה
מלכה - 14.09.2022 15:46

תודה

Ответить
Zarif Ahmed
Zarif Ahmed - 12.08.2022 07:18

This is the best coding channel, it has giga chad

Ответить
Dominic Hoevenagel
Dominic Hoevenagel - 20.05.2022 13:14

You have good clear explained short videos.

Ответить
Rfbu
Rfbu - 31.03.2022 08:28

i like it concise

Ответить
White Dinamo
White Dinamo - 04.02.2022 14:56

lesson check😇

Ответить
BO5
BO5 - 17.12.2021 16:50

thanks bro

Ответить
Random Variable
Random Variable - 01.12.2021 17:55

nice

Ответить
Luc Parent
Luc Parent - 13.09.2021 05:26

thanks

Ответить
Wiktor Augustyniak
Wiktor Augustyniak - 27.08.2021 12:14

awesome work, u rox

Ответить
SpartanRanger
SpartanRanger - 26.08.2021 19:46

Thanks for the video Bro.

Ответить
Hoe Tran
Hoe Tran - 11.07.2021 06:16

Thanks Bro!

Ответить