title: How to detect whether the Property value(ReferenceType property) is changed in c#?
body: <p>I have a <code>Customer</code> class, I would like to get notified when the user has changed the value of the <code>Customer.CityInfo</code> property. </p>
  
  <pre><code>public class City
  {
      public long Id {get;set;}
      public string Code {get;set;}
  }
  
  public class Customer
  {
  
      private City cityInfo;
      private string name;
  
      public long Id { get; set; }
      public bool IsCityModified { get; set;}
      public bool IsCustomerNameModified { get; set; }
  
      public string Name 
      { 
          get{ return name;} 
          set
          {
             if(name!=value)
             {
                IsCustomerNameModified=true; }name=value;
             } 
          }
       }
  
  
      public City CityInfo 
      {
      get
          {
             if(cityInfo==null)
             {
                cityInfo=new City();
             }
             return cityInfo;
           }
  
        set{
            if(this.cityInfo!=value)
            {
               IsCityModified =true;
            }
            this.cityInfo=value;
         }   
    }
  }
  
  public ActionResult Save()
  {
      Customer customer=this.currentCustomerSession;
      if(TryUpdateModel&lt;Customer&gt;(customer)){
         UpdateModel&lt;Customer&gt;(customer)
      }
      if(customer.IsCustomerNameModified ){
          //I am able to detect whether the customerName value has been changed in the frontend.
      }
      if(customer.IsCityModified){
          //I am not able to detect whether the city value has been changed in the frontend.
      }
  }
  </code></pre>
  
  <p>I could set the flag(IsCustomerNameModified) to true if the Customer Name changed since its a value type. But Not able to detect the changes done in Reference Types. </p>
  
  <p>Could anyone help?</p>