Delphi中的方括号是什么意思?

12

有人能告诉我下面的方括号的作用是什么吗?它们叫什么名字,我可以在谷歌上搜索一下。我不知道在搜索框中应该输入什么...

type
  [Entity]
  [Automapping]
  TPerson = class
  private
    FId: integer;
    FLastName: string;
    FFirstName: string;
    FEmail: string;
  public
    property Id: integer read FId;
    property LastName: string read FLastName write FLastName;
    property FirstName: string read FFirstName write FFirstName;
    property Email: string read FEmail write FEmail;
  end;

寻找有关自定义类属性的内容。 - TLama
2个回答

8

这些是修饰类的属性

属性是Delphi语言的一项功能,允许使用特殊对象为类型和类型成员添加注释,并携带额外的信息。这些信息可以在运行时查询。属性使用面向方面编程元素扩展了普通面向对象模型。 一般情况下,属性在构建通用框架时很有用,这些框架可以在运行时分析结构化类型,例如对象或记录,并根据注释属性提供的额外信息引入新行为。

这是与其他语言中的注解相当的功能。


以下是两个有助于理解属性的网页链接:http://delphi.about.com/od/oopindelphi/a/delphi-attributes-understanding-using-attributes-in-delphi.htm 和 http://francois-piette.blogspot.nl/2013/01/using-custom-attribute-for-data.html - Jan Doggen
非常感谢,:) 我会仔细研究的。这确实让我困惑了,因为我以前从未遇到过它们。 - Meh Nada

5
这些是属性 - 一种语言特性,允许使用特殊对象对类型和类型成员进行注释,以携带额外的信息。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接