How to Create a Read-Only Object Property in C#?
As can be seen below, the user is able to change the readonly product field/property: class Program { static void Main(string[] args) { var product = Product.Create("Orange"); var order = Order.Create(product); order.Product.Name = "Banana"; // Main method shouldn't be able to change any property of product! } } public class Order { public Order(Product product) { this.Product = product; } public readonly Product Product; public static Order Create(Product product) { return new Order (product); } } public class Product { private Product(){} public string Name { get; set; } public static