spacer
Yehuda Shiran May 8, 2002
Defining the Enumeration Data Type
Tips: May 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

Symbolic names you declare within the enum statement are numbered sequentially, starting at zero. In the following example:

  enum tvNetworkType {
    ABC,
    CBS,
    NBC,
    FOX
  }
the enumerated values are:

  ABC = 0;
  CBS = 1;
  NBC = 2;
  FOX = 3;
You can declare the underlying type of enumerated variable to be any integral data type, i.e. one of the following: int, short, long, byte, uint, ushort, ulong, or sbyte.

By default, the underlying data type of an enumeration is int. To save space, you can declare the underlying type of tvNetworkType to be of type byte:

  enum tvNetworkType : byte {
    ABC,
    CBS,
    NBC,
    FOX
  }
To learn more on JScript .NET, go to Column 108, JScript .NET, Part II: Major Features.


People who read this tip also read these tips:

Look for similar tips by subject:


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS · Sending an HTML and Plain Text E-newsletter with ASP.NET, Part 2
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Top 10 Threats to Wireless Security · Poll: UC Uptake on the Rise · Review: Fluke AirCheck Wi-Fi Tester 1.0