21.1 ENUM DECLARATIONS

xiaoxiao2021-04-05  231

An Enum Declaration Declares A New Enum Type. An Enum Declaration Begins

With the keyword enum, and

Defines the name, accessibility, underlying type, and membrate of the enum.

ENUM-DECLATION:

AttributeSopt Enum-ModifierSopt Enum Identifier Enum-Baseopt Enum-Body; OPT

ENUM-BASE:

: Integral-Type

ENUM-BODY:

{enum-member-declarationsopt}

{ENUM-Member-Declarations,}

Each ENUM TYPE HAS a Corresponding Integral Type Called The Underlying Type

of the enum type. this

Underlying Type Must Be Able To Repesent All The Enumerator Values ​​Defined

In the enumeration. an enum

Declaration May Explicitly Declare An Underlying Type of Byte, Sbyte,

Short, ushort, int, uint, long

Or Ulong. [NOT: CHAR Cannot Be Used as an underlying type. End Note] An

ENUM DECLATION That Does Not

Explicitly Declare An Underlying Type of Int.

[EXAMPLE: THE EXAMPLE

ENUM color: long

{

RED,

Green,

Blue

}

DECLARES An Enum with an underlying type of long. End Example] [NOTE: A

Developer Might Choose To Use An

Underlying Type of Long, As in the Example, To Enable The Use of Values

That Are in the Range of Long But Not

In The Range of Int, or To Preserve this option for the fulure. End Note]

转载请注明原文地址:https://www.9cbs.com/read-131985.html

New Post(0)