title: Storing functions in C# class properties?
body: <p>I need to create a list containing Device objects. These objects have properties that describe  their Name, Unit and Conversion. Conversion is a bit special as this is supposed to be a function. For example: If I had a temperature sensor measuing in farenheit, its conversion method should calculate and return the value in celsius. And if I have a moisture sensor, its conversion will be different etc. Below is an example of how I have tried doing this but it doesn't work. I get errors saying that only assignment is allowed on Conversion. </p>
  
  <pre><code>private class Device
  {
      public string Name { get; set; }
      public Action Conversion { get; set; }
      public string Unit { get; set; }
  }
  
  public static object ParseDecentLab(byte[] bytes)
  {
  
      List&lt;Device&gt; deviceList = new List&lt;Device&gt;()
      {
          new Device()
          {
              Name = "battery-voltage",
              Conversion = (x) =&gt; x / 1000,
              Unit = "V"
          },
          new Device()
          {
              Name = "air-temperature",
              Conversion = (x) =&gt; (175 * x / 65535) - 45,
              Unit = "°C"
          }
      };
  </code></pre>