How to create enum dynamically?

后端 未结 4 601
感情败类
感情败类 2021-01-17 09:47

I need to create an enum based on a table from the database.

DB table MyColors: id/title/value 1/Red/1 2/Green/4

dynamic create

enum          


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-17 10:09

    You can dynamically create source code by reading from the database and simply outputting the results in a format conducive to building an enum. However, it is impractical to create an enum at run time. You would be better off with some kind of associative array.

提交回复
热议问题