public class Product
{
private int productId;
private string name;
private string description;
private decimal price;
public int ProductId
{
get
{ return productId; }
set
{
productId = value;
}
}
public string Name
{
get
{ return name; }
set
{
name = value;
}
}
public string Description
{
get
{ return description; }
set
{
description = value;
}
}
public decimal Price
{
get
{ return price; }
set
{
price = value;
}
}
}
The above class uses the regular ways you define properties that are exposed to other classes. Even though there are only get/set properties. The auto implemented version of the class requires a lot less typing. public class Product
{
public int ProductId { get; set; }
public string Name { get; set;}
public string Description { get; set; }
public decimal Price { get; set; }
}
The properties do not have be define as a private member of the class. This pattern is called the field-backed property pattern. This means that the C# compiler will take care of the private members fields for us when we build our classes.
The above example are mutable properties, meaning outside classes can change the values of the properties.To create immutable properties, all you have to do is add the keyword private to the set; accessors. Immutable properties, means that the properties are only changeable within the class itself. Outside classes can only read the properties.
public class Product
{
public int ProductId { get; private set; }
public string Name { get; private set;}
public string Description { private get; set; }
public decimal Price { get; private set; }
}
Aivivu - đại lý chuyên vé máy bay trong nước và quốc tế
ReplyDeletemua ve may bay di my
khi nào có chuyến bay từ mỹ về việt nam
lich bay tu duc ve viet nam
vé máy bay từ nga về việt nam
bay từ anh về việt nam
bay từ pháp về việt nam mấy tiếng
Chi phí cho chuyên gia nước ngoài
2F1FC8D2B9
ReplyDeletekiralık hacker
hacker arıyorum
kiralık hacker
hacker arıyorum
belek
DBE4F89D36
ReplyDeletebayan takipçi
swivel glider accent chair
5B076655
ReplyDeleteBartın
Mardin
Ordu
Çankırı
Bingöl
Tekirdağ
Amasya
Kütahya
Bayburt
5DF37C8E
ReplyDeleteKızılay
Lapseki
Avşa
Beypazarı
Finike
Seferihisar
İlkadım
Gökçeada
Tavşanlı
5E4BCCA0
ReplyDeleteAvşa
Ezine
Yıldırım
Kalkan
Bandırma
Nizip
Payas
Esenkent
Cide
D91D11AB
ReplyDeleteMut
Başiskele
Derince
Artuklu
Serik
Sarıçam
Gelibolu
Yeşilyurt
Arsuz
DE5621F9
ReplyDeleteArsuz
Tire
Cebeci
Didim
Etlik
Gökçeada
Karşıyaka
Dilovası
Beyoğlu