1. Class va Object

zahro_11eecc01a1cfe5142b9

Zahro

Posted on October 11, 2024

1. Class va Object

a)C# da class nima?

Class – bu ob'ektlar uchun shablon bo'lib, field va methods kabi ma'lumotlar va xatti-harakatlarni o'z ichiga oladi. Har bir ob'ekt sinf asosida yaratiladi va o'ziga xos ma'lumotlarga ega bo'ladi.

b)Object nima?

Ob'ekt – sinfdan olingan konkret nusxa bo'lib, sinfdagi ma'lumotlar va funksiyalar bilan ishlash imkonini beradi. Sinf – shablon, ob'ekt esa uning amaliy ko'rinishidir.

c)Quidagi kodning natijasini ayting:

Class Car
{
    public string Model;
    public Car(string model)
    {
        Model = model;
    }
}
Car myCar = new Car("Tesla");
Console.WriteLine(myCar.Model);

Enter fullscreen mode Exit fullscreen mode

Natija: Tesla

💖 💪 🙅 🚩
zahro_11eecc01a1cfe5142b9
Zahro

Posted on October 11, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related