博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
delphi 枚举类型与字符串的转换
阅读量:4679 次
发布时间:2019-06-09

本文共 674 字,大约阅读时间需要 2 分钟。

uses

Classes,TypInfo;

 

type

TCommandType = (ctEmptyCommand,ctAdd,ctModify);
TCommandTypeConvert=class
public
class function CommandToString(ACommand: TCommandType): string;
class function StringToCommand(const AStrCommand: string): TCommandType;
end;
implementation
class function TCommandTypeConvert.CommandToString(ACommand: TCommandType): string;
begin
Result := GetEnumName(TypeInfo(TCommandType),Ord(ACommand));
end;
class function TCommandTypeConvert.StringToCommand(const AStrCommand: string): TCommandType;
begin
Result := TCommandType(GetEnumValue(TypeInfo(TCommandType), AStrCommand));
end;
end.

转载于:https://www.cnblogs.com/brightsea/archive/2012/08/15/2639622.html

你可能感兴趣的文章