Delphi枚举类型与整形的转换示例
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, StdCtrls, Buttons, TypInfo;
type
TDemoType = (dta, dtb, dtc);
TForm1 = class(TForm)
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
aDemoType := TDemoType(StrToInt(Edit1.Text));
ShowMessage(GetEnumName(TypeInfo(TDemoType),Ord(aDemoType)));
end;
end.