title: Dictionary<T, Func>: how to use T as Func's generic type?
body: <p>I didn't know how to express it clearly.</p>
  
  <p>I have this interface:</p>
  
  <pre><code>interface IConverter
  {
      Dictionary&lt;Type, Func&lt;string, object&gt;&gt; ConversionMethods { get; }
  }
  </code></pre>
  
  <p>Basically, it defines a contract saying that a class implementing it should provide conversion methods for all the custom types it uses (be them enums or anything).</p>
  
  <p>Is it possible to replace <code>object</code> in <code>Func</code>'s generic types with its corresponding dictionary key's type (so it is impossible to have two unmatching types)?</p>
  
  <p><em>I think it's not possible, but the alternatives are a bit annoying (using <code>dynamic</code> or <code>object</code>, creating a specialized dictionary...).</em></p>
  
  <hr>
  
  <p>edit 1: Imaginary exemple of use</p>
  
  <pre><code>interface IConverter
  {
      Dictionary&lt;Type, Func&lt;string, object&gt;&gt; GetConversionMethods();
  }
  
  enum A
  {
      AA,AB,AC
  }
  
  enum B
  {
      BA, BB, BC
  }
  
  class blah : IConverter
  {
      public Dictionary&lt;Type, Func&lt;string, object&gt;&gt; GetConversionMethods()
      {
          var d = new Dictionary&lt;Type, Func&lt;string, object&gt;&gt;
          {
              {
                  typeof(A),
                  (s) =&gt;
                      {
                          // here, I could return whatever I want because the 'Func' returns 'object'
                          return s == "AA" ? A.AA : s == "AB" ? A.AB : A.AC;
                      }
              },
              {
                  typeof(B),
                  (s) =&gt;
                      {
                          // same
                          return s == "BA" ? B.BA : s == "BB" ? B.BB : B.BC;
                      }
              }
          };
          return d;
      }
  
      void blahah()
      {
          // and here, I also get an `object`, where I would like to have a A
          GetConversionMethods()[typeof(A)]("123");
      }
  }
  </code></pre>