Discussion :: Enumerations - General Questions (Q.No.1)
|Raja Ashutosh Nayak said: (Dec 17, 2011)|
|The value of variable can be assign to a enum variable for that you need to type cast the variable to enum type.
public enum Volume : byte
Low = 1,
string volString = Console.ReadLine();
int volInt = Int32.Parse(volString);
Volume myVolume = (Volume)volInt;
|Nicholas Mahbouby said: (May 8, 2014)|
|In your example you are changing the value of your instance of Volume. Answer 4 was referring to an individual element within the enum declaration.
For example the following declaration would be illegal.
public enum Volume
Low = x,
Medium = y,
High = z
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.