c# - Can you have an enum with a string property? -


i trying develop light client/server program(s). 'admin' program shall able send common commands several local client machines client program installed.

i have enum control common commands so:

public enum command {     reboot,     startservice,     showmsg } 

with can send commands admin program this:

command.reboot 

and on client program can have switch statement asked command.

however, parts of enum need string property send this.

like admin program, send this:

command.showmsg("hi, string message") 

how accomplish this? hope understand question.

you have class, contains enum, so:

enum commandtype {     reboot,     startservice,     showmsg } [datacontract] class command {     [datamember]     public commandtype cmdtype     {         get;         set;     }     [datamember]     public string value     {         get;         set;     }     public commandtype(commandtype cmd, string value = null)     {         cmdtype = cmd;         value = value;     } } 

and use when needed:

new command(commandtype.showmsg, "hi, string message."); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -