How can I make an “abstract” enum in a .NET class library?

后端 未结 7 427
谎友^
谎友^ 2020-12-29 10:17

I\'m making a server library in which the packet association is done by enum.

public enum ServerOperationCode : byte
{
    LoginResponse = 0x00,
    Selectio         


        
7条回答
  •  被撕碎了的回忆
    2020-12-29 10:45

    If you mean to say that you want an enum that can be extended by clients of the library, check out my CodeProject article on the topic, Symbols as extensible enums.

    Note that in my library, Symbol chooses ID numbers for the "enum values" automatically, since it is designed for use inside a single program rather than for exchanging values on a network. Perhaps it would be possible, however, to alter Symbol.cs to your liking so that clients can assign constant values to symbols.

提交回复
热议问题