How to check If a Enum contain a number?

后端 未结 4 1399
遥遥无期
遥遥无期 2021-02-02 05:06

I have a Enum like this:

 public enum PromotionTypes
{
    Unspecified = 0, 
    InternalEvent = 1,
    ExternalEvent = 2,
    GeneralMailing = 3,  
    VisitBas         


        
4条回答
  •  野性不改
    2021-02-02 05:42

    You should use Enum.IsDefined.

    I tried Enum.IsDefine but it only check the String value.

    I'm 100% sure it will check both string value and int(the underlying) value, at least on my machine.

提交回复
热议问题