Access an enum using an index in C

后端 未结 4 1480
梦毁少年i
梦毁少年i 2021-01-13 09:17

Consider:

enum Test
{
    a = 3,
    b = 7,
    c = 1
};

I want to access the enum using an index. Something like this:

for         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-13 09:32

    You can't do that. A C enum is not much more than a bunch of constants. There's no type-safety or reflection that you might get in a C# or Java enum.

提交回复
热议问题