zoukankan      html  css  js  c++  java
  • Handbook之016:Delphi开放数组

    开发数组,参数用const限定词,Slice为取部分长度的数组成员。也可以直接用 [] 的方式传参

    image

    代码如下:

    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows,
      Winapi.Messages,
      System.SysUtils,
      System.Variants,
      System.Classes,
      Vcl.Graphics,
      Vcl.Controls,
      Vcl.Forms,
      Vcl.Dialogs,
      Vcl.StdCtrls;
    
    type
      TForm1 = class(TForm)
        Memo1: TMemo;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    uses
      System.Diagnostics,
      System.Math;
    
    type
      TDays = array of Integer;
    //函数定义
    
    procedure ShowOpenArrays(const AArrayInt: array of Integer);
    var
      I: Integer;
    begin
      for I := Low(AArrayInt) to High(AArrayInt) do
      begin
        Form1.Memo1.Lines.Add('开放数组[' + I.toString + '] := ' + AArrayInt[I].toString);
      end;
    end;
    
    //计时
    procedure TForm1.Button1Click(Sender: TObject);
    var
      m_ArrayInt: array[0..2] of Integer;
    begin
      m_ArrayInt[0] := 6;
      m_ArrayInt[1] := 8;
      m_ArrayInt[2] := 12;
      //Slice为取数组部分成员
      ShowOpenArrays(Slice(m_ArrayInt, 2));
      ShowOpenArrays([33,44,520]);
    end;
    
    end.
  • 相关阅读:
    ASP.NET Ajax基础-1
    项目管理必读之书-》人月神话
    Discuz2.5菜鸟解析-1
    Jquery初学者指南-1
    敏捷日记
    精品图书大推荐2
    Jquery初学者指南-2
    纯javaScript脚本来实现Ajax功能例子一
    周五面试笑话一则
    JavaScript基础-4
  • 原文地址:https://www.cnblogs.com/GodPan/p/4908152.html
Copyright © 2011-2022 走看看