Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
C# inheritance ๐Ÿ‘ช
Play lesson

C# tutorial for beginners ๐ŸŽต - C# inheritance ๐Ÿ‘ช

5.0 (6)
48 learners

What you'll learn

This course includes

  • 4 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

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

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere