C Sharp (C#) - Properties and Encapsulation
What will be the output of this code snippet?
class Product {
private decimal price;
public decimal Price {
get => price;
set {
if (value < 0) throw new ArgumentOutOfRangeException();
price = value;
}
}
}
var p = new Product();
p.Price = -5;