spacer
Yehuda Shiran May 11, 2002
Outside-the-Range Enum Values
Tips: May 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

An enumerated variable can assume values outside the range of its declared values. This is convenient if you want to combine two values to create a third one which is not defined as a member. Let's assume we have the following enumeration:

  enum tvNetworkType {
      ABC,
      CBS,
      NBC,
      FOX
    }
The following line demonstrates a combination of the members NBC and FOX:

  var tvCombination : tvNetworkType = tvNetworkType.NBC | tvNetworkType.FOX;
If you print the value of tvCombination above, you would get the value of 12 (the OR combination of 8 and 4).

To learn more about 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.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Creating a Banking Application Deposit Script · Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Best Buy to Market Phone Power VoIP Service · Industry Insiders: Ted Morgan, CEO, Skyhook Wireless · Chip Market Recovering From '08 Collapse