简体   繁体   English

如何在delphi中排除用作数组索引的枚举类型的第一个元素?

[英]How to exclude the first element of an enumerated Type used as an array index in delphi?

I want to exclude the first value of this enumerated type 我想排除此枚举类型的第一个值

type
  TEnum = (val0, val1, val2, val3, val4);

in order to make this array 为了制作这个数组

TBValues: array [low(TEnum)..High(TEnum)] of boolean;

contains only the last n-1 values (in this case n=5). 仅包含最后的n-1个值(在本例中为n = 5)。

I tried this: 我试过这个:

TBValues: array [low(TEnum)+1..High(TEnum)] of boolean; 

but I guess arithmetic operations are not allowed in this case because I'm getting this compiler error 但我想在这种情况下不允许进行算术运算,因为我收到了这个编译错误

E2010 Incompatible types: 'Int64' and 'TEnum' E2010不兼容类型:'Int64'和'TEnum'

How to do this? 这个怎么做?

What about the obvious: 显而易见的是:

TBValues: array [val1..val4] of boolean;

If you want to avoid the actual enum names, you can write it this way: 如果要避免实际的枚举名称,可以这样写:

TBValues: array [Succ(low(TEnum))..High(TEnum)] of boolean;

For more information: 欲获得更多信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM