Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
C# constructors ๐Ÿ‘ท
Play lesson

C# tutorial for beginners ๐ŸŽต - C# constructors ๐Ÿ‘ท

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# constructors tutorial example explained #C# #constuctor #tutorial using System; namespace MyFirstProgram { class Program { static void Main(string[] args) { // constructor = A special method in a class // Same name as the class name // Can be used to assign arguments to fields when creating an object Car car1 = new Car("Ford", "Mustang", 2022, "red"); Car car2 = new Car("Chevy", "Corvette", 2021, "blue"); car1.Drive(); car2.Drive(); Console.ReadKey(); } } class Car { String make; String model; int year; String color; public Car(String make, String model, int year, String color) { this.make = make; this.model = model; this.year = year; this.color = color; } public void Drive() { Console.WriteLine("You drive the " + make + " " + model); } } }

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