DEV Community

Sunnat Qayumov
Sunnat Qayumov

Posted on

3 2 2 2 2

24. Class va Object

a) Class ichida methodni qanday deklaratsiya qilasiz?

  1. Qaytarish turi(return Type)
  2. Metod nomi
  3. Parametrlari ro'yxati
  4. Method tanasi

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

*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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay