C# Enum To String
We can convert an enum to a string by calling the ToString() method of an Enum. The following code example shows how to convert an enum to a string in C#.
class Program
{
static void Main(string[] args)
{
Enum wkday = Weekday.Friday;
Console.WriteLine("Enum string is '{0}'", wkday.ToString());
Console.ReadKey();
}
// Enum
public enum Weekday
{
Monday = 0, Tuesday = 1, Wednesday = 2,
Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7
}
}
Original post
I have an enum SortFilter, which looks like the following:
public enum SortFilter
{
FirstName = 0,
LastName = 1,
Age = 2,
Experience = 3
}
Now, let's say I want to display the string value of an enum in some control. For that, I will have to convert the Enum value to a string. The following code loops through an enum and adds string values to a DropDownList.
SortByList.Items.Clear();
// Conversion from Enum to String
foreach (string item in Enum.GetNames(typeof(ArrayListBinding.SortFilter)))
{
SortByList.Items.Add(item);
}
The following code converts an enum to a string:
string name= Enum.GetName(typeof(ArrayListBinding.SortFilter), SortFilter.FirstName);
Now let's say you have an enum string value, "FirstName", and you want to convert it to an Enum value. The following code converts from a string to an enum value, where Developer.SortingBy is of type SortFilter enumeration:
// Conversion from String to Enum
Developer.SortingBy = (SortFilter)Enum.Parse(typeof(SortFilter), "FirstName");
Summary
This post with code example taught us how to convert an enum into a string in C#.

Rushi MehtaPosted Mar 28, 2019, 1:42 AM
Nice Article. Thanks Mahesh
Ammar ShaukatPosted Mar 9, 2017, 6:42 AM
Yes.. its quite simple with modern C# to convert enum member to string now...
Joe WilsonPosted Mar 8, 2017, 2:46 AM
Thank you for sharing.
Upendra Pratap ShahiPosted Mar 7, 2017, 7:03 AM
Nice one share sir......
Vishal TiwatanePosted Mar 7, 2017, 2:58 AM
Thanks for Update Mahesh
Saber ShaikhPosted Mar 7, 2017, 12:20 AM
Nice article Thank you Mahesh
Nigel FernandesPosted Mar 6, 2017, 11:43 PM
Was just searching for a way to convert enum to string and found many articles. I think now you can directly convert it to string by doing a .ToString() on the enum.
Janak PadhyaPosted Sep 19, 2012, 7:00 PM
Hi, Thanks for Post. it's help me lots.
Bruno PimentaPosted Jun 21, 2011, 2:15 PM
Hi, thanks for the great post. I hope I can help in an update for WPF in VS2010 and Windows 7 Console.Writeline(SortFilter.FirstName.ToString()); Complements, BP