Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Enumeration in C sharp

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 27-01-2010
Member
 
Join Date: Dec 2009
Posts: 23
Enumeration in C sharp
  

I am beginner(fresher) programmer in this programming world. I just loves doing programming, right now i am learning the programming language like C++, C sharp, Core Java, Visual Basic 6, and DBMS. Right now i am doing the mini project in C sharp and i need to know what does enumeration means and why to use it? Please help me.

Reply With Quote
  #2  
Old 27-01-2010
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: Enumeration in C sharp

Enumeration is known as enum(keyword). The enum is usually under a value type which is a set of related named constants and often referred to as an enumerator list. Enumeration are assume to be strong typed constants.
Syntax:
enum identifier (:base-type)
{
enumerator-list
}
Enum will allow code to see a lot cleaner and easier to read by getting rid of 'magic numbers'. The enum will get the numbers which have a purpose within a module of code, but make the code harder to read.
Reply With Quote
  #3  
Old 27-01-2010
Member
 
Join Date: Feb 2008
Posts: 1,845
Re: Enumeration in C sharp

Enumeration is achieved through using the enum keyword. They are assume as strong type constants. The Enum's are overall a unique type which will allow you to assign symbolic names to integral values. And in C sharp, this enum are strongly typed, and it means that one type will not be implicitly assigned to an enum of another type even though the underlying value of their members are the same. Example:
enum Direction
{
North,
East,
South,
West
}
Reply With Quote
  #4  
Old 27-01-2010
Member
 
Join Date: May 2008
Posts: 2,383
Re: Enumeration in C sharp

According to me, in the C sharp, the enum(enumeration) is 'a unique(distinct) set of value types which will declare a set of named constants.' And when you do programming in C sharp, you will have to declare an enum through the enum keyword. Enums are strongly typed constants. Example:
public enum Country
{
India,
USA,
Russia,
SriLanka
}
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #5  
Old 27-01-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Enumeration in C sharp

I personally think the enumeration is most valuable/essential function in C sharp. They are very useful. In the situation, where we need to set a related numbers in a program, and assume the replacing of that numbers with enum's. Due to this, the program will be more readable and type safe. Listing 17-1 contains an enum definition and code that uses that enum in a switch statement. In-replace of using the numbers 0, 1, 2, and 3 in the switch statement, the code will become more meaningful through the use of the Volume enum. Hope your problem will be fix.
Reply With Quote
  #6  
Old 27-01-2010
Member
 
Join Date: Nov 2005
Posts: 1,323
Re: Enumeration in C sharp

My knowledge about C sharp says that, the enums are considered as strong typed constants. The Enum's are essentially unique types which will allow you to assign symbolic names to integral values. I would give you the simple example of how does enumeration works and how to use it:
public enum demoenum
{
X = 1,
Y = 2,
Z = X + Y,
A = X * Z + 33
}
public class EnumerationDemo
{
public static void Member(demoenum d1)
{
// do some processing here
}
public static void Main()
{
demoenum d1 = 0;
Member(d1);
}
}
Hope you will be able to understand all about enumeration.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Enumeration in C sharp"
Thread Thread Starter Forum Replies Last Post
Sharp 007SH Hybrid An 3D Clamshell Android Phone by Sharp jackalz Web News & Trends 3 22-05-2011 08:28 AM
C sharp v/s C plus plus GlassFish Software Development 3 30-01-2011 07:06 AM
What is the difference between Iterator and Enumeration in Java? Karsenman Software Development 4 28-01-2010 09:56 AM
Difference between Structure, Classes and Enumeration Henryosa Software Development 6 22-01-2010 11:02 AM
Do you know any best book for C sharp? Zhankana_n Software Development 3 07-12-2009 09:58 AM


All times are GMT +5.5. The time now is 03:30 PM.