title: Replace Property-Setter Method Ptr
body: <pre><code>public delegate void SetProp(object obj);
  
  void Main()
  {
      TestObj obj = new TestObj();
  
      SetProp setPropDel = (SetProp)SetProp.CreateDelegate(typeof(SetProp), 
      obj, obj.GetSetPropDelegate().GetMethodInfo());
      MethodInfo setPropMethod = setPropDel.GetMethodInfo();
  
      ///Replacing Count Set-Method Pointer with new Method
      typeof(TestObj).GetProperty("Count").GetSetMethod().ReplaceMethodPtr(setPropMethod);
      obj.Count = 1;
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public class TestObj
  {
      public SetProp GetSetPropDelegate() =&gt; SetPropValue;
  
      private void SetPropValue(object obj) =&gt; Console.WriteLine(obj); ///&lt;--- NullReferenceException obj is null.
  
      public int Count { get; set; }
  </code></pre>
  
  <p>}</p>
  
  <p>Hi, I was trying to replace the private set-Method for the auto-Property "Count" in my class TestObj.</p>
  
  <p>The replacement itself works. Because when I use the setter like 'obj.Count = 1' the new method is being called.</p>
  
  <p>My question is: Is it possible to pass a parameter into this new method?
  I'd at least need the new value that is being allocated to the Count-Property. In this case: 1.</p>
  
  <p>My goal is to make it possible to replace Set-Methods of automatic properties to raise an event, when the new Set-Method is being called, and also keep basic function of the Set-Method.</p>
  
  <p>I hope it's clear what I want to achieve. I might've run into something impossible here, but I'm sure there are lots of people have a much better understand of what's going on.</p>
  
  <p>Thanks for reading.</p>