C# Programming - Enumerations - Discussion

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


Which of the following statements is true about an enum used in C#.NET?

[A]. An implicit cast is needed to convert from enum type to an integral type.
[B]. An enum variable cannot have a public access modifier.
[C]. An enum variable cannot have a private access modifier.
[D]. An enum variable can be defined inside a class or a namespace.
[E]. An enum variable cannot have a protected access modifier.

Answer: Option D


No answer description available for this question.

Bhupendra Singh said: (Jul 6, 2012)  
We can define a enum at both place, either inside a namespace or inside class, it will work properly.

Option b, d, e is wrong because we can use access modifier with enum.

Rama Lanka said: (Jan 31, 2016)  
But also option A is true. Isn't it?

Nagaraju Kuricheti said: (Feb 9, 2017)  
Yes, option A is also true.

We need to convert it implicitly.
int a=(int)enum_name.Namedintegerconstant;.

Ataman said: (May 31, 2021)  
@Nagaraju Kuricheti,

You did it in an explicit way.

Explicit casting.
double myDouble = 9.78;
int myInt = (int) myDouble;

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.