How do you return an Enum from a setter/getter function?
Currently I have this:
public enum LowerCase
{
a,
b,
}
public en
I think you may have misunderstood the reasons for using enumerations. An enumeration is a special type of variable that can only take a specific set of values. For example. a boolean is a very special case of enumeration. A boolean variable is one that can only take 2 values - Either "true" or "false".
You have defined an enumeration:
public enum LowerCase { a, b, }
This means that a variable of type LowerCase
will only be able to be set to either a, or b. This isn't really much use.
Your other enumeration is more sensible:
public enum Case { Upper, Lower, }A variable of type Case can be set to either "Upper" or "Lower". Now when you define a variable of an enumeration type, you specify the type you want it to be. You have done this:
private Enum case;but what think you mean is:
private Case case;This defines a private variable of type
Case
called case
. The enum keyword is only used when you are defining a new enumeration, not when you are defining a variable of an enumeration type.
Similarly, where you have defined your property, you should use the enum type that you want to return:
public Case ChooseCase {...And where you are trying to return a enumeration value, you should be doing this:
return Case.Lower