title: C#: Unable to cast object of type 'System.Int64' to type 'System.Int32'
body: <p>I have code as follows:</p>
  
  <pre><code>Dictionary&lt;object, object&gt; dict = ...
  Color = (int)dict.GetValue("color");
  </code></pre>
  
  <p>When I convert the Color to an int, I get the following exception:</p>
  
  <blockquote>
    <p>System.InvalidCastException: Unable to cast object of type
    'System.Int64' to type 'System.Int32'.</p>
  </blockquote>
  
  <p>I am not sure why I can't just cast from a long to an int. I know for a fact that the value is less than <code>0xFFFFFF</code> (24 bits) since it is a color.</p>
  
  <p>I tried using <code>unchecked</code> but that didn't help either.</p>