How to check If a Enum contain a number?

后端 未结 4 1456
遥遥无期
遥遥无期 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:25

    Maybe you want to check and use the enum of the string value:

    string strType;
    if(Enum.TryParse(strType, out MyEnum myEnum))
    {
        // use myEnum
    }
    

提交回复
热议问题