刀妃

得于斯者毁于斯

博客园 首页 新随笔 联系 订阅 管理

声明:
1. type Name = Existing type;
   2. type Name = type Existing type;
   3. type Name = (EnumValue1 [=value], EnumValue2 [=value] ...);
   4. type Name = Expression1..Expression2;   

 5. type Name = ^Existing type;
   6. type Name = array[...] of Existing type;   

 7. type Name = class ... end;
   8. type Name = class of Existing class   

 9. type Name = dispinterface ... end;  

 10. type Name = file of Existing type;  

 11. type Name = function ...;
 12. type Name = interface ...  end;  

 13. type Name = object ... end;  

 14. type Name = procedure ...;

15. type Name = record ... end;
  16. type Name = set of Ordinal values
描述:Type关键词是Delphi的基础部分,不像其它语言,它允许创建变量和过程的新类型(种类)。这些新的类型可以被引用,就像它是语言的一部分一样。 比如:Type TCourtCards = (Ace,Jack,Queen,King); 
允许定义一个这种“type”的新变量:var Card:TCourtCard; Card:=Queen; 一般都在类型名字的前缀加“T”,这是一种有用的约定。 1.type Name = Existing type
参考一个现有的类型,比如用新的名字来替代string。 2.type Name = type Existing type
这个与上面的效果一样,但是它确保在运行时,这个类型的变量被识别为它的新类型名称,而不是原先已存在的类型名称。
3.type Name = (EnumValue1,EnumValue2„)
定义一个枚举类型,包含了值EnumValue1,EnumValue2等等。它是用户自定义的名字,列举出所有有可能的值。这些值在你的程序中必 须是唯一的,一旦在类型中定义了它,只可通过两种方法引用:指定或引用一个这种类型的变量;和用Ord关键词取得序数作为数字值.

见例子。
注:这些枚举元素在定义的时候,它的位置值为0,1,2,等等,除非这个值用“=value”覆写。如:
Type Days = (Monday = 1,Tuesday,Wed„);
这里,Monday位置值被设为1,Tuesday为2,Wednesday 为3,依次类推。 4.Type Name = Expression1..Expression2
这里是一个完整的整数或字符范围,从Expression1表达式到Expression2表达式。表达式1和2可以是计算结结果为整数或字符的公式,或仅是整数或字符常量。如:Type TAlphabet =’A’..’z';通常用于定义字符范围,从大写A到小写z。 5.type Name = ^Existing type
‘^’符号是指向现有类型的指针。它经常用于导航记录Record类型。 6.type Name = array[„] of existing type 一个结构类型,用一个新的类型封装了某类型的数组。 7.type Name = class„end
用于定义一个新类的结构,详见Class关键词。 8.type Name = class of existing class 提供一个meta-class定义,详见Class关键词。 9.type Name = dispinterface „ end
一个分派接口(dispatch interface)类型,详见Dispinterface关键词。 10.type Name = file of Existing type
定义一个指向文件的类型,这个文件包含了给定类型的记录。(默认地,文件包含二进制数据)
11.type Name = function „
定义一个函数当作类型,允许这个函数被定义作为参数用于子程序。 12.type Name = interface „ end

posted on 2014-04-08 16:52  刀妃  阅读(101)  评论(0编辑  收藏  举报