枚举类型:项数限制? [英] Enumerated Type: Limit to number of items?
问题描述
在Delphi中,枚举类型中可以包含的项数是否有限制?我需要创建一个可能包含数百个项目的枚举类型,并想要确保例如255个项目没有限制。
Is there a limit in Delphi to the number of items you can have in an enumerated type? I need to create an enumerated type that might have several hundred items, and want to make sure there is not a limit at 255 items for example.
type
TMyType = (mtOne, mtTwo, mtThree, ..., mtThreeHundred);
推荐答案
我在德国德尔福市最多发现65535个物品
I found a maximum of 65535 items in a german Delphi book.
在对文档进行一些挖掘之后,我找到了相应的部分:
After some digging in the documenation I found the respective section:
如果枚举的
不超过256个值并且在,则枚举类型存储为
无符号字节。 > {$ Z1} 状态(默认
)。如果枚举类型的
多于256个值,或者类型
是在{$ Z2}
状态中声明的,则为
存储为无符号字。如果在
{$ Z4}
状态中声明了
枚举类型,则将其存储为
无符号双字。 / p>
An enumerated type is stored as an unsigned byte if the enumeration has no more than 256 values and the type was declared in the
{$Z1}
state (the default). If an enumerated type has more than 256 values, or if the type was declared in the{$Z2}
state, it is stored as an unsigned word. If an enumerated type is declared in the{$Z4}
state, it is stored as an unsigned double-word.
因此,实际上最多应该有4294967295( $ FFFFFFFF
)项目。
So in fact there should be a possible maximum of 4294967295 ($FFFFFFFF
) items.
这篇关于枚举类型:项数限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!