Generating Enums Dynamically

后端 未结 4 1892
旧巷少年郎
旧巷少年郎 2020-12-10 02:18

Let\'s say I have a file whose format is basic XML, like so:



    
        SomeEnum<         


        
4条回答
  •  长情又很酷
    2020-12-10 02:54

    Actually it is possible to create enum instances dynamically, but it's a total hack, I wouldn't advise it at all - maybe you're misunderstanding the nature of an enum, it's a compile-time feature of the language, and you're not supposed to add/remove instances from it at runtime.

    Anyway, if you're interested in the hack for creating enum instances dynamically, take a look at this article.

提交回复
热议问题