Skip to content

Conversation

@reflectronic
Copy link
Contributor

In C#, generally, casts to enum types inside of enum initializers cause things to stop working. For example:

public enum E1
{
    F = 3
}

public enum E2
{
    M = E1.F + E1.F, // Compiles fine
    E = (E1) E1.F + E1.F // Does not work!
}

Removing all casts to enum types when inside an enum initializer avoids these issues.

@reflectronic reflectronic changed the title Remove casts to enum types in enum initializers Insert cast to enum underlying type when casting to enum type in enum initializer Jan 30, 2021
@tannergooding tannergooding merged commit 3a04181 into dotnet:master Jan 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants