The Code Fix

#️⃣ شرح C#

الأصناف والكائنات (OOP)

الصنف والكائن

class Car {
    public string Brand;
    public int Speed;

    public void Drive() {
        Console.WriteLine($"{Brand} بسرعة {Speed}");
    }
}

class Program {
    static void Main() {
        Car myCar = new Car();
        myCar.Brand = "Toyota";
        myCar.Speed = 120;
        myCar.Drive();
    }
}

الباني (Constructor)

class Car {
    public string Brand;
    public Car(string brand) {
        Brand = brand;
    }
}

Car c = new Car("Honda");

الخصائص (Properties)

ميزة مميّزة في C# للتغليف الأنيق:

class Account {
    private double balance;

    public double Balance {
        get { return balance; }
        set { balance = value; }
    }
}

أو المختصرة:

public string Name { get; set; }

الوراثة

class Animal {
    public void Eat() => Console.WriteLine("يأكل");
}

class Dog : Animal {
    public void Bark() => Console.WriteLine("ينبح");
}

Dog يرث Eat() ويضيف Bark().

🎉 أكملت أساسيات C#! أصبحت جاهزًا لتطوير التطبيقات والألعاب مع Unity. اختبر نفسك واحصل على شهادتك.