首页 > 代码库 > 数组与枚举
数组与枚举
万一老师博客:http://www.cnblogs.com/del/archive/2008/01/09/1031196.html
----------------------------------------------------------------------------------------
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;
数组与枚举
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。