C# static 🚫

Tác giả: Bro Code
Ngày xuất bản: 2021-07-03T00:00:00
Length: 05: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!");

}

}

}

Dịch Vào Lúc: 2025-06-22T05:35:48Z

Yêu cầu dịch (Một bản dịch khoảng 5 phút)

Phiên bản 3 (ổn định)

Tối ưu hóa cho một người nói. Phù hợp cho video chia sẻ kiến thức hoặc giảng dạy.

Video Đề Xuất