Get a enum value

This question already has an answer here:

  • Get int value from enum in C# 24 answers

  • Just cast the enum value to int .

    A a = new A();
    
    int k = (int)a.NumberOfFiscalPeriod;
    

    The inverse is valid too, even if there is no enum value defined for that int value, for sample:

    int i = 13; // int value
    EFiscalPeriond f = (EFiscalPeriond) i; // converting int to enum
    
    链接地址: http://www.djcxy.com/p/91792.html

    上一篇: 从枚举中显示int值

    下一篇: 获得一个枚举值