title: C# unable to cast from implementation to interface within generic
body: <p>I obviously don't understand generics, inheritance and casting at some or all levels.  I'm trying to do something which seems to me perfectly sensible.  In fact, the code I have here is an attempt to get around the problem at a higher level with reflection, but taking that out of the equation, I feel I at least need to understand why the following doesn't work.</p>
  <p>I get the following compiler error on the <code>GenericDescriptors</code> return statement:</p>
  <blockquote>
  <p>Error CS0039  Cannot convert type 'System.Collections.Generic.Dictionary&lt;string, System.Action&lt;Question.MyType1, System.Collections.Generic.List&gt;&gt;' to 'System.Collections.Generic.Dictionary&lt;string, System.Action&lt;Question.IMyType, System.Collections.Generic.List&gt;&gt;' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion</p>
  </blockquote>
  <p>The code is:</p>
  <pre><code>public interface IMyType
  {
  
  }
  
  public class MyType1 : IMyType
  {
      public const string ValueDescriptor = &quot;MyTypeValue&quot;;
  
      public static Action&lt;MyType1, List&lt;string&gt;&gt; ValueSetter = (result, items) =&gt; result.Value = items;
  
      public List&lt;string&gt; Value { get; set; }
  
      public static Dictionary&lt;string, Action&lt;MyType1, List&lt;string&gt;&gt;&gt; Descriptors
      {
          get
          {
              return new Dictionary&lt;string, Action&lt;MyType1, List&lt;string&gt;&gt;&gt;()
              {
                  { ValueDescriptor, ValueSetter }
              };
          }
      }
  
      public static Dictionary&lt;string, Action&lt;IMyType, List&lt;string&gt;&gt;&gt; GenericDescriptors
      {
          get
          {
              return Descriptors as Dictionary&lt;string, Action&lt;IMyType, List&lt;string&gt;&gt;&gt;;
          }
      }
  }
  </code></pre>
  <p>Can someone help me understand what is wrong with the above?  Isn't the thing I'm trying to cast the thing I'm trying to cast to?  I understand I couldn't go the opposite direction, from an interface to an implementation of it - but from an implementation to an interface... seems perfectly legit.</p>