Answer Posted / srinivasan
Enum is a type for which the memory will be allocated on the stack instead of the heap. It can be used to write presentable code in place where we will be using integers. For Ex.
Enum Declaration
private Enum OperationalResult
{
Success = 1,
Failure = 2
}
Enum Usage
Switch (result)
{
case: (int)OperationalResult.Success
MessageBox.Show("Yippe,Operation Success");
break;
case: (int)OperationalResult.Failure
MessageBox.Show("OOPS! It's a failure");
break;
default:
MessageBox.Show("OOPS! Canno determine");
break;
}
Here in the above code, if the following statement
(int)OperationalResult.Success is replaced with 1, it does not make sense and a new developer looking at the wouldn't understand what 1 represents.
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
What is the difference between abstract and abstraction?
What do you mean by a windows process in regards to memory allocation?
What are the collection types can be used in c#?
What are the properties of a string class?
Name some properties of thread class.
What is boxing? Explain its functionality?
What is the difference between double and decimal in c#?
What is the difference between == and object.equals?
What is the namespcae generally given to the webpage of the .NET Framework ?
What is a satellite assembly in c#?
What is ilasm.exe used for?
Is exe is machine dependent?
What are the different types of classes in c#?
how to sort an array in c#
What is final keyword in c#?