Results 1 to 6 of 6

Thread: Enumeration in C sharp

  1. #1
    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.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    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.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    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
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    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
    }

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    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.

  6. #6
    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,710,826,296.38663 seconds with 16 queries