DEV Community

Firdavs Mukhsimov
Firdavs Mukhsimov

Posted on

Class va Object

a) C# dasturlash tilida objectni qanday yaratasiz?

class ClassName //sinf yaratish
{
// Fields (ma'lumotlar)
// Methods (xatti-harakatlar)
}
b) Quyidagi kodda qanday xato bor?

class Person
{
public string Name;

public int Age;
Enter fullscreen mode Exit fullscreen mode

}
Person p;
p.Name = "John";
Xato: Person p deb yaratib bo'lmaydi. To'g'ri kod: Person p = new Person();

Top comments (0)