用ord() 如: type test=(aaa, bbb, ccc);ord(bbb)=1;//序号从零开始
var i:integer; s:string; a:Colors; begin s:='bb'; a:=low(colors); i:=1; while a<>high(colors) do begin if s=(GetEnumName(TypeInfo(Colors),i-1)) then begin showmessage('存在'); end ; i:=i+1; a:=succ(a); end; showmessage(inttostr(i)); end;
好象是GetEnumValue之类的
ttest = (aaa, bbb, ccc);
枚举类型定义是用标识符,不是”字符串”,而且不能超过255个。typinfo.pasAname = GetEnumName(TypeInfo(Ttest), 0); /// 返回 'aaa'
如:
type test=(aaa, bbb, ccc);ord(bbb)=1;//序号从零开始
i:integer;
s:string;
a:Colors;
begin
s:='bb';
a:=low(colors);
i:=1;
while a<>high(colors) do
begin
if s=(GetEnumName(TypeInfo(Colors),i-1)) then
begin
showmessage('存在');
end ;
i:=i+1;
a:=succ(a);
end;
showmessage(inttostr(i));
end;