Live Chat Icon For mobile
Live Chat Icon

How can I convert an Enumeration member to string and vice-versa

Platform: WinForms| Category: Strings

To convert an enum to string, do this:


string enumEntryAsString = Enum.GetName(typeof(TabSizeMode), TabSizeMode.FillToRight);

To convert a string to an enum type:


// Enclose this code within try/catch.
TabSizeMode sizeMode = Enum.Parse(typeof(TabSizeMode), '1');
(or)
TabSizeMode sizeMode = Enum.Parse(typeof(TabSizeMode), 'FillToRight');

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.