Just want to make sure.
public class Product { private decimal unitPrice; public int Id { get; set; } public string Code { get; set; } public string Name { get; set; } //private string code; public decimal Unitprice { get { return unitPrice; } set { if (value >=0) unitPrice = value; } } }
Why we would have to make private variable to unitPrice to return the value to UnitPrice, does it written for some reasons ?