DEV Community

Xojimurodov
Xojimurodov

Posted on

Class va Constructor

1) Constructor nima?
Construktor – bu sinfdan obekt yaratilganda avtomatik ravishda chaqiriladigan maxsus usuldir. U ob'ektning dastlabki qiymatlarini o'rnatish uchun ishlatiladi.

2)
class Animal
{
public string Name;
public Animal(Name)
{
Name = name;
}
}
Animal dog = new Animal("Dog");
Console.WriteLine("dog.Name);

Top comments (0)