Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is ENUM?

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


Please Help Members By Posting Answers For Below Questions

What is collection of classes in c#?

1017


Enlist some of the properties of a thread class?

925


How objects are stored in memory?

1021


What are the fundamental differences between value types and reference types?

1070


Explain when should you call the garbage collector in .net?

912


What does an indexer do?

890


Can constructor be protected in c#?

940


What is difference between array and arraylist c#?

1040


What is int32 in c#?

884


What do you mean by object pooling?

1028


What Is A Multicast Delegate?

1063


Can you store different types in an array in c#?

961


Explain About CLS?

972


What will be the output of the following code?

925


What to implement on my class Finalize or IDisposable

979