zoukankan      html  css  js  c++  java
  • Array of const 形式的参数可以传递不同类型的参数

        正如你所能想到的,由于Array of const 形式的参数可以传递不同类型的参数,使得接收这些参数的函数和过程工作起来比较困难。作为一个例子,下面的代码是WhatHaveIGot()过程的实现,在这个例子中依次判断每一个数据的类型,并在屏幕上显示数据的序号和类型:

    

    procedure WhatHaveIGot(A : Array of Const);
    var
      i : integer;
      TypeStr : string;
    begin
      for i := Low(A) to High(A)do
      begin
        Case A[i].VType of
          VtInteger    : TypeStr := 'Integer';
          VtBoolean    : TypeStr := 'Boolean';
          VtChar       : TypeStr := 'Char';
          VtExtended   : Typestr := 'Extended';
          VtString     : TypeStr := 'String';
          Vtpointer    : TypeStr := 'Pointer';
          VtPChar      : TypeStr := 'PChar';
          Vtobject     : TypeStr := 'Object';
          Vtclass      : TypeStr := 'Class';
          VtwideChar   : TypeStr := 'WideChar';
          VtPWideChar  : TypeStr := 'PWideChar';
          VtAnsiString  : TypeStr := 'AnsiString';
          VtCurrency   : TypeStr := 'Currency';
          VtVariant    : TypeStr := 'Variant';
          VtInterface  : TypeStr := 'Interface';
          VtwideString : TypeStr := 'WideString';
          VtInt64      : TypeStr := 'Int64';
        end;
        ShowMessage(ForMat('Array item %d is a a %s',[i, TypeStr]));
      end;
    end;
    
    
  • 相关阅读:
    Chap5:操作文件和目录[The Linux Command Line]
    ABC3
    ABC2
    ABC
    Spring MVC / Boot
    Usefull Resources
    [ Learning ] Design Pattens
    [ Learning ] Spring Resources
    URL Resources
    [ Windows BAT Script ] BAT 脚本获取windows权限
  • 原文地址:https://www.cnblogs.com/beeone/p/1812530.html
Copyright © 2011-2022 走看看