Return Enum From C# Property getters

前端 未结 7 985
谎友^
谎友^ 2021-01-21 14:35

How do you return an Enum from a setter/getter function?

Currently I have this:

    public enum LowerCase
    {
        a,
        b,
    }
    public en         


        
7条回答
  •  星月不相逢
    2021-01-21 15:03

    You're mixing two enumerations together which is not a good idea since it defeats the purpose of the enum type.

    Definitely do not cast to int and do comparisons that way -- you lose the ability to change the order of your enumerated values in future versions.

提交回复
热议问题