title: How to Create a Read-Only Object Property in C#?
body: <p>As can be seen below, the user is able to change the readonly product field/property:</p>
  
  <pre><code>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 Product Create(string name)
          {
              return new Product { Name = name };
          }
      }
  </code></pre>
  
  <p>I thought it's quite basic but it doesn't seem so.</p>
  
  <p>How to Create a Read-Only Object Property or Field in C#?!</p>
  
  <p>Thanks,</p>