How to Resolve Error "CS0076: The enumerator name 'value__' is reserved and cannot be used" in C#
The Compiler Error CS0076 is a naming conflict error specific to Enums. The message reads: "The enumerator name 'value__' is reserved and cannot be used".
In C#, an enum is not just a list of names; it is a distinct value type backed by an integral type (usually int). Under the hood, the Common Language Runtime (CLR) automatically generates a special instance field named value__ to store the actual numeric value of the enum instance. Because this field exists internally, the compiler prevents you from defining an enum member with the exact same name to avoid ambiguity and data corruption.
This guide explains the internal structure of Enums and how to choose valid member names.
Understanding the Reserved Name
When you compile an Enum like public enum Color { Red, Blue }, the CLR generates a struct that looks roughly like this in Intermediate Language (IL):
// Pseudo-code of what the CLR generates internally
public struct Color : System.Enum
{
// This is the backing field that holds the actual number (e.g., 0 or 1)
public int value__;
public static const Color Red = 0;
public static const Color Blue = 1;
}
Because value__ (all lowercase, two underscores) is the hardcoded name for the data storage field, C# forbids you from using it as a member name in any enum.
This restriction applies specifically to the exact string value__. It does not apply to Value__ (capital V), _value, or __value, although using double underscores is generally discouraged in .NET naming conventions.
Scenario: The Forbidden Name
This error occurs when a developer tries to create an enum member that maps to an underlying value or tries to expose a "raw value" member using this specific naming convention.
Example of error:
public enum TransactionState
{
Pending = 1,
Completed = 2,
// ⛔️ Error CS0076: The enumerator name 'value__' is reserved
// and cannot be used.
value__ = 3,
Failed = 4
}
Solution: Rename the Member
The solution is simply to choose a different name. PascalCase is the standard convention for Enum members in C#, so Value (with a capital V) is perfectly valid.
public enum TransactionState
{
Pending = 1,
Completed = 2,
// ✅ Correct: 'Value' (PascalCase) does not conflict with internal fields.
Value = 3,
// ✅ Correct: 'RawValue' is also a descriptive alternative.
RawValue = 4,
Failed = 5
}
Conclusion
CS0076 is a system restriction to protect the internal mechanics of the .NET Runtime.
- Avoid
value__: Never name an enum member exactlyvalue__. - Use PascalCase: Stick to standard C# naming conventions (e.g.,
Value,InnerValue), which naturally avoid this specific lowercase reserved identifier.