C# enum contains value

后端 未结 10 654
轮回少年
轮回少年 2020-12-07 23:46

I have an enum

enum myEnum2 { ab, st, top, under, below}

I would like to write a function to test if a given value is included in myEnum

10条回答
  •  离开以前
    2020-12-08 00:28

    just cast the enum as:

    string something = (string)myEnum;
    

    and now comparison is easy as you like

提交回复
热议问题