Class Constructor
Sabrina
Posted on October 11, 2024
a) Constructor nima?
Javob : Konstruktor – bu sinfdan obyekt yaratilganda avtomatik ravishda chaqiriladigan maxsus usuldir. U obyektning dastlabki qiymatlarini o'rnatish uchun ishlatiladi. Konstruktor sinf nomi bilan bir xil bo'ladi va u hech qanday qaytarish tipiga ega bo‘lmaydi.
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);
💖 💪 🙅 🚩
Sabrina
Posted on October 11, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.