DEV Community

Mushtariy
Mushtariy

Posted on

Class va Object

a) C# dasturlash tilida objectni qanday yaratasiz?

class o'zimizaxolagannom //sinf yaratish
{
    // Fields (ma'lumotlar)
    // Methods (harakatlar)
}
Enter fullscreen mode Exit fullscreen mode

b) Quyidagi kodda qanday xato bor?

class Person
{
    public string Name;
    public int Age;
}
Person p;
p.Name = "John";
Enter fullscreen mode Exit fullscreen mode

Javob: Person p emas Person p = new Person(); bo'ladi.

Top comments (0)