码迷,mamicode.com
首页 > 编程语言 > 详细

枚举类型互相转换(使用GetEnumName和TypeInfo两个函数)

时间:2016-03-19 00:43:18      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:

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. 

http://blog.csdn.net/tercel99/article/details/7791652

枚举类型互相转换(使用GetEnumName和TypeInfo两个函数)

标签:

原文地址:http://www.cnblogs.com/findumars/p/5294102.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!