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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
HP to Microsoft: Thanks for Nothing
iPhone Remains Left Out as Android Scores Flash
The Year of Living the OpenSocial
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:

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script · Book Review: Content Rich
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Gateway Launches New Core i7-powered FX-Series Gaming PCs · Review: Lenovo ThinkPad SL300 · EBay, Alternative Site Holiday Resources for Sellers