title: C#: Convert a generic function to a Func object
body: <p>I have the following function:</p>
  
  <pre><code>private int GetEnumTypeUnderlyingId&lt;T&gt;()
          {
              return (int)Enum.Parse(typeof(T), Enum.GetName(typeof(T), _franchise.LogonDialog));
          }
  </code></pre>
  
  <p>I want to convert it to a <code>Func type</code>. I write something like:</p>
  
  <pre><code>Func&lt;int&gt; GetEnumTypeUnderlyingIdFunc&lt;T&gt; = () =&gt; (int)Enum.Parse(typeof(T), Enum.GetName(typeof(T), _franchise.LogonDialog));
  </code></pre>
  
  <p>But this does not work. I am not really comfortable when working with Func&lt;>, Generics and lambda expressions so any help will be greatly appreciated</p>