I. Definition of Enum
Public
Enum
Userrolestype
...
{
Unknown
=
0
,
Basesimple
=
70
,
Basebasic
=
71
,
Baseextend
=
72
,
Basebasic2
=
88
,
Basesimple2
=
89
,
Baseextend2
=
90
}
Method 1:
Retrieve enumeration objects by ID
Protected
Userrolestype getenum (
Int
T)
...
{
Bool
Isinenum
=
False
;
Userrolestype C
=
Userrolestype. Unknown;
If
(T
>
0
)
...
{
Foreach
(
Int
I
In
Enum. getvalues (
Typeof
(Userrolestype )))
...
{
If
(I
=
T)
...
{
//
This. debug (T. tostring (),"");
C
=
(Userrolestype) enum. parse (
Typeof
(Userrolestype), I. tostring ());
Isinenum
=
True
;
Return
C;
//
(Colors) enum. parse (typeof (colors), "red, yellow ");
}
}
If
(Isinenum
=
False
)
...
{
Return
Userrolestype. Unknown;
}
}
Return
C;
}
Method 2: Obtain the enumeration name by ID
Protected
String
Getenumname (
Int
S)
...
{
String
Str
=
Enum. getname (
Typeof
(Userrolestype), S );
If
(Str
=
Null
)
...
{
Str
=
Userrolestype. Unknown. tostring ();
}
Return
STR;
}