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

后端 未结 7 373
谎友^
谎友^ 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:48

    If there is a database that is shared between your client and server application, then look-up tables may help; the table structure just contain an integer value (ID) and a string (the name), this table can be filled out by either side of your application (the client or the server) and read by the other. You can cache these table (in your code) in a dictionary for quick look-up.

    You can also implement the same thing in the app.config file; force the user of your library to set these values in the app.config file which your library can access easily.

提交回复
热议问题