.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Post New Resource Bookmark and Share   

Call Enum value in C#.net

Posted By:Narayanan       Posted Date: August 02, 2012    Points: 40    Category:    URL: http://www.dotnetspark.com  

Here I give a Sample code for call Enumeration value in C#.net
 

Create Enum:

   enum days
        {
            Monday=1,
            Friday,
            Sunday
        }

Method for output value:

private void listofdays(string str)
        {
            switch (str)
            {
                case "Monday":
                    MessageBox.Show(str);
                    break;
                case "Friday" :
                    MessageBox.Show(str);
                    break;
                case "Sunday":
                    MessageBox.Show(str);
                    break;

           }
           
        }

Result:
listofdays(Convert.ToString(days.Monday));
Message box will show  "Monday"

Note: Developer can convert Enumerate value into string by using Convert.ToString() Method

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend