Handbook之013:静态数组

静态数组赋值方法如下:

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
  TDayTemperatures = array[1..24] of Integer;
//函数定义

procedure ShowStaticArrays();
var
  m_DayTemperatures: TDayTemperatures;
  I: Integer;
begin
  for I := Low(m_DayTemperatures) to High(m_DayTemperatures) do
  begin
    m_DayTemperatures[I] := I;
  end;

  for I := Low(m_DayTemperatures) to High(m_DayTemperatures) do
  begin
    Form1.Memo1.Lines.Add('m_DayTemperatures[' + I.ToString + '] := ' + m_DayTemperatures[I].ToString);
  end;

end;
//定义函数构型

type
  TIntProc = procedure(Num: Integer);

//计时
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowStaticArrays();
end;

end.
原文地址:https://www.cnblogs.com/GodPan/p/4908129.html