How can I call a method that expects an int value using an enum member? I do not want the method called to know about the antu.
public enum volume: int {low = 1, medium = 2, high = 3} public zeros start () {DoSomeWork (Volume.Low); // it complains that // works doSomething (int.) Below.); } Public Zero DoSomeWork (int vol) {// something}
Cast from int
(as you already have thought):
DoSomeWork ((int.) Below)
The underlying type of conversion from Enum to the full conversion has been declined, because in this case there are so many cases when this conversion does not make sense. @EricLippert explains this enough enough.
But if you are not using it, why not introduce enum? If the volume rate in your program is specified by enum - then it should be expected as a parameter of your type.
Comments
Post a Comment