title: Convert.ChangeType and converting to enums?
body: <p>I got an <code>Int16</code> value, from the database, and need to convert this to an enum type. This is unfortunately done in a layer of the code that knows very little about the objects except for what it can gather through reflection.</p>
  
  <p>As such, it ends up calling <code>Convert.ChangeType</code> which fails with an invalid cast exception.</p>
  
  <p>I found what I consider a smelly workaround, like this:</p>
  
  <pre><code>String name = Enum.GetName(destinationType, value);
  Object enumValue = Enum.Parse(destinationType, name, false);
  </code></pre>
  
  <p>Is there a better way, so that I don't have to move through this String operation?</p>
  
  <p>Here's a short, but complete, program that can be used if anyone need to experiment:</p>
  
  <pre><code>using System;
  
  public class MyClass
  {
      public enum DummyEnum
      {
          Value0,
          Value1
      }
  
      public static void Main()
      {
          Int16 value = 1;
          Type destinationType = typeof(DummyEnum);
  
          String name = Enum.GetName(destinationType, value);
          Object enumValue = Enum.Parse(destinationType, name, false);
  
          Console.WriteLine("" + value + " = " + enumValue);
      }
  }
  </code></pre>