Search code examples
.netenumspinvokemarshalling

Are .net Enums blittable types? (Marshalling)


Apparently there's a list of blittable types and so far I don't see Enums specifically on it. Are they blittable in general? Or does it depend on whether they are declared with a blittable base type?

//e.g.
internal enum SERVERCALL : uint
{
    IsHandled = 0,
    Rejected = 1,
    RetryLater = 2,
}

References exhausted:


Solution

  • Enums are blittable types. From the enum keyword documentation:

    Every enumeration type has an underlying type, which can be any integral type except char.

    Because the underlying type is integral (all of which are on the list of blittable types), the enum is also blittable.