Skip to content

sizeof on enum types #54499

Description

@GeeLaw

Type of issue

Missing information

Description

sizeof on an enum type is a compile-time constant and it's the size of that enum type at compile-time. This could be surprising at first --- and it means if an enum's underlying type (from a referenced assembly) is modified after compilation, the code needs to recompile.

This fact should be mentioned in the documentation.

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/sizeof

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/operators/sizeof.md

Document Version Independent Id

7e28a662-f550-d202-9a97-e684ae1b074d

Platform Id

86e8a1a6-0fd2-822f-93d0-d5ec8ddc72b0

Article author

@BillWagner

Metadata

  • ID: 191acdd8-8e36-8bd4-1172-140717c36a85
  • PlatformId: 86e8a1a6-0fd2-822f-93d0-d5ec8ddc72b0
  • Service: dotnet-csharp
  • Sub-service: lang-reference

Related Issues

Activity

  1. added
    needs-more-info
    on Jun 23, 2026
  2. GeeLaw commented on Jun 23, 2026

    @GeeLaw
    Author

    @BillWagner Could you reopen the issue, now with proper feedback information? It was closed by the bot due to "lack of information", but the issue creation page will constantly reset feedback text into [Enter feedback here] so it's very unergonomic to create an issue with any feedback text. (Yes, I can try pasting the text and clicking "Create" very fast before the offending reset kicks in, but...)

  3. Sem909 commented on Jun 23, 2026

    @Sem909

    Open

  4. added
    ⌚ Not Triaged
    help wanted
    and removed
    needs-more-info
    ⌚ Not Triaged
    on Jun 23, 2026
  5. heissenberg06 commented on Jun 28, 2026

    @heissenberg06
    Contributor

    I'd like to pick this up. I'll add a bullet to the sizeof operator page noting that sizeof on an enum type yields the size of its underlying integral type, that the size is evaluated at compile time, and that changing the underlying type of an enum in a referenced assembly requires recompiling consumers to observe the new size. PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dotnet-csharp/svchelp wantedlang-reference/subsvc

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions