✅ Enum and generics
Hello there!
In our current code, we use structs to represent a packet;
This packet (struct) has a
This
This isn't ideal, so I considered using an Enum to represent the packet Id's, however that would mean that the packets would be in 2 places, the enum and the
Is there a way to combine this? The ideal solution would be an enum with generic
But that is obviously not supported.
In our current code, we use structs to represent a packet;
Packet<Data>.This packet (struct) has a
ushort Identifier and a Codec<Data> Codec.This
Identifier should be unique, but currently we assign these manually:This isn't ideal, so I considered using an Enum to represent the packet Id's, however that would mean that the packets would be in 2 places, the enum and the
Packet instance holding the codec.Is there a way to combine this? The ideal solution would be an enum with generic
<Data> to allow enforcing the codec used:But that is obviously not supported.