Define enum representation type in C# -
i know, there posibility in c#
change default (integer)
representation of enum
less weight char
.
many of ask me why want it? answer simple:
i have work @ huge, huge array
. pc allow me allocate memory array of integer 540 000 000 elements (2048 * 2048 * 128). know integer
needs aroud 4 times more memory char
.
char
representation give me 2 000 000 000
elements manipulate.
much easier in programming masive algorithms work @ enum
char
if change of representation isn't possible have work on charracters.
yes, can change type of enum not char
. byte
can work it's 1 byte type. check enum (c# reference) on msdn (emphasis mine):
every enumeration type has underlying type, can integral type except char. default underlying type of enumeration elements int. declare enum of integral type, such byte, use colon after identifier followed type, shown in following example.
enum days : byte {sat, sun, mon, tue, wed, thu, fri};
the approved types enum
byte
,sbyte
,short
,ushort
,int
,uint
,long
, orulong
.
Comments
Post a Comment