C# Programming - Enumerations - Discussion

Discussion Forum : 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.
1, 2
3, 4
4, 5
1, 4
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
2 comments Page 1 of 1.

Nicholas Mahbouby said:   1 decade ago
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
}

Raja ashutosh nayak said:   1 decade ago
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;

Post your comments here:

Your comments will be displayed after verification.