title: C# cast object of type int to nullable enum
body: <p>I just need to be able to cast an object to nullable enum. Object can be enum, null, or int. Thanks!</p>
  
  <pre><code>public enum MyEnum { A, B }
  void Put(object value)
  {
      System.Nullable&lt;Myenum&gt; val = (System.Nullable&lt;MyEnum&gt;)value;
  }
  
  Put(null);     // works
  Put(Myenum.B); // works
  Put(1);        // Invalid cast exception!!
  </code></pre>