c# - How to add a setter when there is a custom getter? -


i have modify existing code , stumped on getter setter. how add setter code?

public virtual string sku {     { return product.id.trim(); } } 

depending on want in setter. if want assign value product.id should this:

public virtual string sku {     { return product.id.trim(); }     set { product.id = value; } } 

in case set private field this:

private string _sku;  public virtual string sku {     { return product.id.trim(); }     set { _sku = value; } } 

but bit akward have setter set field, whereas when getting value different.

the natural solution seem be:

private string _sku;  public virtual string sku {     { return _sku.trim(); }     set { _sku = value; } } 

but not know exact rules of business logic.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -