How can I make an "abstract" enum in a .NET class library?
Posted
by Lazlo
on Stack Overflow
See other posts from Stack Overflow
or by Lazlo
Published on 2010-06-13T02:59:52Z
Indexed on
2010/06/13
3:02 UTC
Read the original article
Hit count: 334
I'm making a server library in which the packet association is done by enum.
public enum ServerOperationCode : byte
{
LoginResponse = 0x00,
SelectionResponse = 0x01,
BlahBlahResponse = 0x02
}
public enum ClientOperationCode : byte
{
LoginRequest = 0x00,
SelectionRequest = 0x01,
BlahBlahRequest = 0x02
}
That works fine when you're working in your own project - you can compare which enum member is returned (i.e. if (packet.OperationCode == ClientOperationCode.LoginRequest)
). However, since this is a class library, the user will have to define its own enum.
Therefore, I have two enums to add as "abstract" - ServerOperationCode and ClientOperationCode. I know it's not possible to implement abstract enums in C#. How would I go doing this?
© Stack Overflow or respective owner