May 10, 2002 - Setting the Enum Values | WebReference

May 10, 2002 - Setting the Enum Values

Yehuda Shiran May 10, 2002
Setting the Enum Values
Tips: May 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

An enum value in JScript .NET is accessed as an object member. The name of the member should be prefixed by the name of the enumeration, for example tvNetworkType.ABC. When you assign a value to an enumerated variable, you can use a full name (such as tvNetworkType.ABC), a string representation of the name ("ABC"), or a numeric value (1).

When you use a string that is known at compile time, the compiler will perform the necessary conversion. For example, "ABC" would be replaced by tvNetworkType.ABC. If the string is not known at compile time, a conversion will be made at run time. That conversion may fail if the string is not a valid member of the enumerated type. It's a good practice to avoid run-time assignments of enumerated variables. It takes precious CPU time, and it may end up in an error.

To learn more on JScript .NET, go to Column 108, JScript .NET, Part II: Major Features.