title: Directcast & Ctype differences with enums
body: <pre><code> Public Enum Fruit
      Red_Apple = 1
      Oranges
      Ripe_Banana
  End Enum
  Private Sub InitCombosRegular()
      Dim d1 As New Dictionary(Of Int16, String)
      For Each e In [Enum].GetValues(GetType(Fruit))
          d1.Add(CShort(e), Replace(e.ToString, "_", " "))
      Next
      ComboBox1.DataSource = d1.ToList
      ComboBox1.DisplayMember = "Value"
      ComboBox1.ValueMember = "Key"
      ComboBox1.SelectedIndex = 0
  End Sub
  
     'This fails
          Dim combo1 = DirectCast(ComboBox1.SelectedValue, Fruit) ' Fails
          'these both work
          Dim combo2 = DirectCast(CInt(ComboBox1.SelectedValue), Fruit) 'works
          Dim combo3 = CType(ComboBox1.SelectedValue, Fruit) 'works
  </code></pre>
  
  <p>Why does the <code>CType</code> work and the <code>DirectCast</code> does not with the same syntax? Yet if I cast the <code>selectedValue</code> to an <code>int</code> before I <code>DirectCast</code>, then it works</p>
  
  <p>Regards</p>
  
  <p>_Eric</p>