An enumeration is a set of named integer constants.
Enumerations are value types
Enumerations are especially suitable for representing types that can take one of a set of fixed values.
They must always be fully qualified with the enumeration type name.
The default type is "int" although the type can also be (byte, sbyte, short, ushort, uint, long, ulong)

public enum enShapes   // defaults to int 
   [Stop] //Stop is a reserved word

enShapes Shape = enShapes.Triangle;

byte Data Type

public enum enShapes : byte 

GetName Method

This retrieves the name of the constant instead of the numerical value


If numerical values are not specified then
1 plus the previous constant is used
0 is used for the first constant

Enumerations are value types and they differ from the abstract System::Enum class which in turn derives from System::ValueType
Any Enum you define in your application derives from the System.Enum, which in turn inherits from System.ValueType.
If no explicit value is provided for the first member inside the Enum block is assigned the value 0, the second is assigned 1, etc
You are encouraged not to change the initial value.
Enum blocks can appear anywhere in a source file, an inside module, a class or a structure block or directly at the namespace level

GetNames Method

This returns a string array of the names of the constants in the enumeration.

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext