如何在Delphi中将单个枚举值标记为已弃用

时间:2012-02-23 23:05:33

标签: delphi enums delphi-xe2 deprecated

我希望得到以下内容:

TEnumType = (
  etValue1 = 1,
  etValue2 = 2 deprecated,
  etValue3 = 3);

它返回:

[DCC Error] unt_CollectionImportType.pas(19): E2029 ',' or ')' expected 
but identifier 'deprecated' found.

是否有办法指示编译器不推荐使用此值。

1 个答案:

答案 0 :(得分:36)

type
  TEnumType = (
    etValue1 = 1,
    etDeprecated2 = 2, // was: etValue2; Renamed so we can deprecate it by name
    etValue3 = 3);

const
   etValue2 = etDeprecated2 deprecated; // Declares a constant mapped to the renamed enum value.