DEV Community

Ozodbek
Ozodbek

Posted on

Properties in C# | Uzbek

Salom barchaga. Bugun biza C# dasturlash tilida o'rganishimiz kerak bo'lgan ba'zi bir tushunchalar haqida aytib beraman.
`** Reja: **

  • Property nima ?
  • Property turlari
  • Propertydan foydalanish
  • Amaliyot va tushunchalar
  • Quizlar`

*Property nima ? *
Property(xususiyat) C# dasturlash tilida obyektlar, classlar va strukturalar ichida ma'lumotni saqlash va olish uchun ishlatiladigan maxsus a'zolar(member)dir. Propertylar fieldlar(maydonlar) kabi ko'rinadi. Va ular getter va setter orqali maydonga kirish imkonyatini beradi.

Property turlari: **
1 - **Auto implemented property
- Bu turdagi propertylar soddalashtirilgan holda yoziladi, bu yerda get va set methodlari automatik ravishda yoziladi.
2 - Read-Only Property - Faqat o'qish uchun belgilangan propertylar. get funksiyasi ishlaydi xolos, set qo'sha olmaymiz.
3 - Write-Only Property - Faqat yozish mumkin bo'lgan propertylar, faqat set metodi bilan ta'minlanadi.
4 - Calculated Properties - Hisob kitobli propertylar, get va set methodlari maxsus hisob-kitoblarni amalga oshirish uchun ishlatiladi.

Amaliyotni boshladik πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€

Auto-Implemented Property

public class Person 
{
    public string Name { get; set; }
    public int Age { get; set; }
}
Enter fullscreen mode Exit fullscreen mode

*Read-Only Property *

public class Person2 
{
    private string name; 

    public Person2 (string name)
    {
        this.name = name;
    }
    public string Name 
    {
        get {return name;}
    }
}
Enter fullscreen mode Exit fullscreen mode

Write-Only Property

public class Person3 
{
    private string password; 

    public string Password 
    {
        set {password = value;}
    }
}
Enter fullscreen mode Exit fullscreen mode

davomi bor....

Image of Timescale

πŸš€ pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applicationsβ€”without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up