C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Specifying the Base Type of an Enumeration in C#


Posted Date: 10 Jun 2004    Resource Type: Articles    Category: .NET Framework
Author: ANITA MARY JOSEPHMember Level: Gold    
Rating: 1 out of 5Points: 7



Specifying the Base Type of an Enumeration

By default, enumerations are based on the type int. But one can create an enumeration of any integer type, except for type char.

To specify a type other than int, just put the base type after the enumeration name, separated by a colon. For example, the following statement makes colors an enumeration based on byte.

enum colors : byte { Yellow, Green, Blue, red, White };


Now colors.Blue, for example, is a byte quantity.



Responses

Author: Harmeet Singh Sra    06 Sep 2004Member Level: Silver   Points : 0
using this method we can use only numeric data type as base type for enums.
we can not specify string type data Type.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Using Data Access Application Block - I
Previous Resource: Thread Communication Using Wait(), Pulse() and PulseAll()
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use