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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -