Create a deep copy of the Price class by implementing the IClonnable interface. Then, when you set a price, you will say
a.Price = b.Price.Clone();
or
Class Cost{ private Price _price; public Price PriceValue { get { _price.Clone(); } set { _price = value; } } }
that way you will never forget
therefore, you cannot access the _price field directly, unless you name the Getter property, which ultimately returns a deep copy of the price
source share