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 / gnanavel s

enum is a keyword that allows you to declare an enumeration. an enumeration is a set of names for valeus. for example

enum Dificulty {easy,normal,hard};

then you can declare variables of type Dificulty and set it's value as easy/normal/hard

Dificulty d = Dificulty.easy;

enums make your program more readable and help you to don't set integer values incorrectly. remembering easy is easier than remembering 0 or 1. a complete reference is available on MSDN [here.][1]

as you can read there the value is easy is 0 and normal 1 and hard 2. values are increased by one and you can set the values to numbers that you want. the type is a constant integral type. by constant i mean that you can not change the value of Dificulty.easy after defining the enum.

unity uses enums for sending constant values to functions. you can see enums usefulness from Input.GetMouseButton() i always froget what number is for what button but if it had an enum like

enum MouseButton {left,middle,right};

then it was easy to set this just like KeyCode and other available enums.

using enums in javascript is the same but i don't know how to define them in js.

hope this helps.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we override interface methods in c#?

845


What is a clr host?

935


What is the object class in c#?

947


What are Regex / regular expressions ?

1066


can you allow a class to be inherited, but prevent the method from being over-ridden?

951


What is the use of parse in c#?

883


Are value types sealed?

958


How to find the current application file path while runtime?

965


What is the difference between int16 and int32 in c#?

911


Is array thread safe c#?

849


Is equal in c#?

853


What is parallel foreach c#?

928


What is the c# equivalent of c++ catch (…), which was a catch-all statement for any possible exception? Does c# support try-catch-finally blocks?

886


What is the difference between field and variable in c#?

979


What’s a strong name?

976