title: Passing object to an inline function in C#
body: <p>Is it possible to pass a variable (not the value of the variable) to an inline function. See example below (C# / Xamarin Forms).</p>
  <p>For example I would like to pass one property Pressure, then in the inline function get the name of the property &quot;Pressure&quot; and also the value if the property &quot;1000.0&quot; which is then used to set a &quot;Preference&quot;.  The code works below but I feel it is possible to simplify further.  I would be able to use this concept in all sorts of applications.</p>
  <p>Thank you</p>
  <pre><code>void SetPreferences()
  {
      void f(string key, string value) =&gt; Preferences.Set(key, value);
  
      //eg f(&quot;Pressure&quot;, &quot;1000.0&quot;)
      f(nameof(Pressure), Pressure);
  
      //eg f(&quot;Temperature&quot;, &quot;50.0&quot;)
      f(nameof(Temperature), Temperature);
  }
  
  void WhatIWouldLike_SetPreferences()
  {
      void f(object X) =&gt; Preferences.Set(stringnameofX, stringvalueofX);
  
      f(Pressure);
      f(Temperature);
  }
  </code></pre>