C# – Enums

Adding Enum Values to ComboBox

comboBox1.Items.AddRange(System.Enum.GetNames(typeof(importants)));

Converting String to Enum

importants ipt =  (importants)System.ComponentModel.TypeDescriptor.GetConverter(typeof(importants)).ConvertFromString(comboBox1.SelectedItem.ToString());

OR

importantsipt = (importants)System.Enum.Parse(typeof(importants), comboBox1.SelectedItem.ToString());

Getting values from Enum

foreach(int i in Enum.GetValues(typeof(importants))){
MessageBox.Show(i.ToString());
}
Posted in C#

4 thoughts on “C# – Enums

  1. i’m also firefox user.. my blog are working very fine in both firefox and ie.

    could u plz send me a screenshot if you are not able to view my page in firefox? Thanks.

  2. I’m too having Problems with viewing this Page (IE7)

    the lines of code are not Wrapped, it’s a One Long line overlaying the Links panels on the right.
    Thanks for the Code!

Leave a Reply

Your email address will not be published. Required fields are marked *