zoukankan      html  css  js  c++  java
  • Delphi 集合和字符串互转

    集合和字符串互转

     集合:

       

    type
    TSocketState = (ssDisconnecting, ssDisconnected, ssConnected, ssConnecting, ssListening, ssAccepting);

    const
    TSocketStateCaption: array[TSocketState] of String = ('正在断开', '已经断开', '已经连接', '正在连接', '正在侦听', '正在接入');

    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;
    View Code

    调用方法:

        str:=GetEnumName(TypeInfo(TSocketState),Ord(lvClient.SocketState));

  • 相关阅读:
    文字标签和注释标签
    HTML文档的组成和标签的规范
    HTML概述
    javaWeb
    web开发的三层架构
    ASCII码表
    JDK的新特性
    Editplus的运行JAVA的配置
    Eclipse的断点调试
    Eclipse工作空间的基本配置
  • 原文地址:https://www.cnblogs.com/stroll/p/7988434.html
Copyright © 2011-2022 走看看