本文整理自网络,侵删。
数组与枚举
type
TMyEnum = (Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday); {定义枚举}
var
weekArr: array[TMyEnum] of string; {定义数组}
myEnum: TMyEnum; {定义枚举变量}
begin
{数组赋值}
weekArr[Monday] := '星期一';
weekArr[Tuesday] := '星期二';
weekArr[Wednesday] := '星期三';
weekArr[Thursday] := '星期四';
weekArr[Friday] := '星期五';
weekArr[Saturday] := '星期六';
weekArr[Sunday] := '星期天';
{调用数组}
ShowMessage(weekArr[Sunday]); {星期天}
{遍历数组}
for myEnum := Low(weekArr) to High(weekArr) do
begin
ShowMessage(weekArr[myEnum]); {将分别显示: 星期一 ... 星期天}
end;
end;
相关阅读 >>
Delphi 从paintbox拷贝一部分内容到tbitmap
Delphi中操作olevariant、variant和stream
Delphi 如何编写使stringgrid中的一列具有check功能,和checkbox效果一样
winapi 字符及字符串函数(1): charlower - 字符或字符串转小写
更多相关阅读请进入《Delphi》频道 >>