title: Why is Dictionary transformed into a KeyValuePair here?
body: <p>I'm just messing around with some data types of C# in order to understand them.
  I've been trying for a while to understand why this dictionary is turned into a KeyValuePair.
  Here's my code:</p>
  <pre><code>class Program
  {
      static Dictionary&lt;string, int&gt; operatii(int a, int b)
      {
          Dictionary&lt;string, int&gt; calculare = new Dictionary&lt;string, int&gt;();
          calculare.Add(&quot;suma&quot;, a + b);
          calculare.Add(&quot;produs&quot;, a * b);
          return calculare;
      }
  
      static void Main(string[] args)
      {
          foreach(Dictionary&lt;string, int&gt; dict in operatii(5, 6))
          {
              Console.WriteLine();
          }
      }
  }
  </code></pre>
  <p>And I'm getting this error:</p>
  <blockquote>
  <p>Error CS0030  Cannot convert type 'System.Collections.Generic.KeyValuePair&lt;string, int&gt;' to 'System.Collections.Generic.Dictionary&lt;string, int&gt;'</p>
  </blockquote>
  <p>Now as I'm writing this I've understood that my logic was flawed, and the first parameter of the foreach cannot be a Dictionary.</p>
  <p>But how does C# know that this should've been a KeyValuePair? Maybe I really meant to write Dictionary in there, and make the foreach run only once (because I only have one Dictionary).</p>
  <p>Thanks.</p>