Enumerations in C#

You can find the same article in my dotnetspider article from the following link
 
Enumerations in C#

Enumerations are a special kind of data type. Enumerations contain a list of named constants. They can make code more readable, as they allow you to reference constants by using a name instead of the literal value.
In C#, enumerations are declared by using the enum keyword.
Enumerations can be declared as byte, sbyte, short, ushort, int, uint, long and ulong.
By default, enumerations are defined as int.

enum animal
{ 
  Dog,
  Cat,
  Fish,
  Bird
}

A comma must separate each member in the enumeration.
If values for the enumeration members are not explicitly defined, the first member defaults to 0.
In the Animal example, the Dog member equates to 0; the Cat equates to 1, and so on.
Members can be initialized to constant values if needed.


enum Animal
{
  Dog = 3,
  Cat,
  Fish,
  Bird
}

Here, members are initialized starting at 3. Cat equals 4 and so on.
In reality each member can be initialized to any constant expression.
The two preceding examples do not define an underlying type for the enumeration. Animal, in this case, defaults to an integer enumeration. Animal can be defined as a long , as in the following example.

enum Animal : long
{
Dog = 3,
Cat,
Fish,
Bird
}

Here I explained basics of enumerations.
For more information please go through the following links.
http://www.codeproject.com/KB/cs/LocalizingEnums.aspx
http://www.softsteel.co.uk/tutorials/cSharp/lesson7.html


What is GST

GST (Goods and Service Tax) is a comprehensive tax on the supply of goods and services at each stage of any transaction. Read More

Income Tax Information

An income tax is a tax imposed by government on income earned by you. Income tax is a key source of funds that the government uses to fund its activities and serve the public. Read More

General Insurance Companies in India

General insurance is insurance for valuables other than our life and health. General insurance covers the insurer against damage, loss and theft of your valuables. Read More



Types of Bank Loans In India

Loan means lending money from one individual or entity to another. A loan has three components – principal or the borrowed amount, rate of interest and tenure or duration for which the loan is availed. Read More

List of Banks in India

The Reserve Bank of India is the central Bank that is fully owned by the Government of India. It is governed by a central board (headed by a Governor) appointed by the Central Government. Read More

List of Educational Institutions in India

The following list of comprehensive websites on higher education in India. These websites will provide detailed information on education system in India. Read More