Επεξεργασία

Κοινή χρήση μέσω


Boolean-backed enum type support removed

Support for formatting, parsing, and conversions of Boolean-backed enumeration types has been removed.

Previous behavior

Previously, formatting, parsing, or converting a Boolean-backed enumeration type was somewhat functional.

New behavior

Starting in .NET 8, an InvalidOperationException is thrown if you try to format, parse, or convert a Boolean-backed enumeration type.

Version introduced

.NET 8 Preview 1

Type of breaking change

This change is a behavioral change.

Reason for change

This change was made to make the .NET runtime simpler, faster, and smaller. Formatting and parsing Boolean-backed enumeration types is never used in practice and complicates the implementation. Also, Boolean-backed enum types aren't expressible in C#.

If you're using a Boolean-backed enumeration type, use a regular Boolean type or a byte-backed enumeration type instead.

Affected APIs