C#
programming
enums
data conversion
lists

Convert an enum to Liststring

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

In C#, the usual way to convert an enum to List<string> is to ask the runtime for the enum names. The shortest answer is Enum.GetNames(typeof(MyEnum)).ToList(), which gives you a list containing each enum member name as a string.

That works well when you want to populate a dropdown, generate labels, or inspect the enum values dynamically. The exact method you choose depends on whether you want the symbolic names, the numeric values, or some custom display text.

Get the Enum Names Directly

For most cases, this is the simplest solution:

csharp
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
5public enum Status
6{
7    Pending,
8    Approved,
9    Rejected
10}
11
12public class Program
13{
14    public static void Main()
15    {
16        List<string> names = Enum.GetNames(typeof(Status)).ToList();
17        Console.WriteLine(string.Join(", ", names));
18    }
19}

Enum.GetNames returns a string array containing the declared member names. Calling ToList() turns it into List<string>.

Convert Values with LINQ

Another common option is to get the enum values and call ToString on each one:

csharp
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
5public enum Status
6{
7    Pending,
8    Approved,
9    Rejected
10}
11
12List<string> names = Enum.GetValues(typeof(Status))
13    .Cast<Status>()
14    .Select(value => value.ToString())
15    .ToList();

This is slightly more verbose, but it is useful when you want to filter, sort, or transform the values before producing strings.

In newer C# versions you can also use the generic form:

csharp
List<string> names = Enum.GetValues<Status>()
    .Select(value => value.ToString())
    .ToList();

That is often the cleanest version in modern code.

Know What Kind of Strings You Need

There are three common interpretations of this problem:

  • enum member names such as Pending
  • numeric values such as 0, 1, 2
  • display strings such as Pending Approval

Enum.GetNames gives you only the member names. If your UI needs friendly text, you may want attributes or a mapping layer instead of raw enum names.

For example, with a custom mapping:

csharp
1List<string> labels = Enum.GetValues<Status>()
2    .Select(value => value switch
3    {
4        Status.Pending => "Pending Approval",
5        Status.Approved => "Approved",
6        Status.Rejected => "Rejected",
7        _ => value.ToString()
8    })
9    .ToList();

That is better than forcing the enum identifier itself to double as presentation text. It also keeps your public UI language independent from internal naming, which becomes useful when the enum names stay code-friendly but the screen text changes later.

Order and Flags

Enum names are returned in declaration order. That is usually what you want, but it is worth knowing if display order matters. It also means the output is predictable for tests, serialization helpers, and UI components that rely on stable ordering. That predictability is useful in configuration screens and automated assertions.

Also be careful with [Flags] enums. A flags enum represents bit combinations, so converting the declared values to strings is fine, but converting arbitrary combined values may produce composite text that is different from the raw member names.

Common Pitfalls

  • Using Enum.GetValues when Enum.GetNames would be simpler for plain name lists.
  • Assuming enum names are automatically suitable as user-facing labels.
  • Forgetting to call ToList() when a real List<string> is required instead of an enumerable.
  • Treating flags enums like ordinary enums without considering combined values.

Summary

  • The direct answer is Enum.GetNames(typeof(MyEnum)).ToList().
  • Use Enum.GetValues<T>().Select(x => x.ToString()).ToList() when you want more control over transformation.
  • Decide whether you need enum names, numeric values, or friendly display labels.
  • Keep UI labels separate from enum identifiers when presentation text matters.
  • Be careful with flags enums because combined values behave differently from simple enums.

Course illustration
Course illustration

All Rights Reserved.