DEV Community

Firdavs Mukhsimov
Firdavs Mukhsimov

Posted on

Class va Object

a) Class ichida methodni qanday deklaratsiya qilasiz?

Qaytarish turi(return Type)
Metod nomi
Parametrlari ro'yxati
Method tanasi

class ClassName
{
    // Qaytarish turi, metod nomi va parametrlar
    public int MyMethod(int param1, string param2)
    {
        // Metodning tanasi
        return result;  // Qaytarish qiymati
    }
}
Enter fullscreen mode Exit fullscreen mode

b) Quyidagi koddagi this kalit so'zining ma'nosini tushuntiring:

class Person
{
    public string Name;
    public Person(string name)
    {
        this.Name = name;
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)