Can you add to an enum type in run-time

后端 未结 6 650
甜味超标
甜味超标 2020-12-08 07:06

If I have an enum type:

public enum Sport
{
    Tennis = 0;
    Football = 1;
    Squash = 2;
    Volleyball = 3;
}

Can I somehow add durin

6条回答
  •  清歌不尽
    2020-12-08 07:17

    If the enum can be defined at program startup, you place the enum in a separate assembly and use a bootstrapper that will recompile the enum, overwriting the old version, and then launch the actual application. It's not the cleanest method, but it works.

提交回复
热议问题