C# Programming - Enumerations - Discussion

Discussion :: Enumerations - General Questions (Q.No.1)

1. 

Which of the following statements are correct about an enum used inC#.NET?

  1. By default the first enumerator has the value equal to the number of elements present in the list.
  2. The value of each successive enumerator is decreased by 1.
  3. An enumerator contains white space in its name.
  4. A variable cannot be assigned to an enum element.
  5. Values of enum elements cannot be populated from a database.

[A]. 1, 2
[B]. 3, 4
[C]. 4, 5
[D]. 1, 4

Answer: Option C

Explanation:

No answer description available for this question.

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,
Medium,
High
}
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:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.