Back to Browse

C# static 🚫

119.6K views
Jul 3, 2021
5:02

C# static modifier tutorial example explained #C# #static #modifier using System; namespace MyFirstProgram { class Program { static void Main(string[] args) { // static = modifier to declare a static member, which belongs to the class itself // rather than to any specific object Car car1 = new Car("Mustang"); Car car2 = new Car("Corvette"); Car car3 = new Car("Lambo"); Console.WriteLine(Car.numberOfCars); Car.StartRace(); Console.ReadKey(); } } class Car { String model; public static int numberOfCars; public Car(String model) { this.model = model; numberOfCars++; } public static void StartRace() { Console.WriteLine("The race has begun!"); } } }

Download

1 formats

Video Formats

360pmp46.8 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

C# static 🚫 | NatokHD