title: Generic functions and ref returns in C# 7.0
body: <p>Is it possible to use the ref returns feature in C# 7.0 define a generic function that can do both comparison and update of a field in two instances of an Object?  I am imagining something like this:</p>
  
  <pre><code>void UpdateIfChanged&lt;TClass, TField&gt;(TClass c1, TClass c2, Func&lt;TClass, TField&gt; getter)
  {
      if (!getter(c1).Equals(getter(c2))
      {
          getter(c1) = getter(c2);
      }
  }
  </code></pre>
  
  <p>Example intended usage:</p>
  
  <pre><code>Thing thing1 = new Thing(field1: 0, field2: "foo");
  Thing thing2 = new Thing(field1: -5, field2: "foo");
  UpdateIfChanged(thing1, thing2, (Thing t) =&gt; ref t.field1);
  UpdateIfChanged(thing1, thing2, (Thing t) =&gt; ref t.field2);
  </code></pre>
  
  <p>Is there any way to specify a Func type or any kind of generic type restriction that would make this valid by requiring that getter return a reference? I tried <code>Func&lt;TClass, ref TField&gt;</code>, but it doesn't appear to be valid syntax.</p>