Class va Constructor

mushtariy

Mushtariy

Posted on October 11, 2024

Class va Constructor

a) Constructor nima?

Construktor – sinfdan obyekt yaratilganda avtomatik chaqiriladigan maxsus usuldir. U obyekning dastlabki qiymatini o'rnatish uchun ishlatiladi.

b)Quyidagi kodni to'ldiring:

class Animal
{
   public string Name;
   public Animal(string name)
   {
      Name = name;
   }
}
Animal dog = new Animal("Dog");
Console.WriteLine(dog.Name);
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
mushtariy
Mushtariy

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