是否可能:记录中的数组
我有下一个数组
NAMES1: array[0..1] of string = ('NO1','NAME1');
NAMES2: array[0..1] of string = ('NO2','NAME2');
和一个记录结构
TMyRec = record(
Name: ????;
);
结果我需要声明一个常量记录数组,如下所示
const
StringArraysList: array[0..1] of TMyRec = (
(Name: NAMES1),
(Name: NAMES2)
);
问题是我应该为 TMyRec 中的名称选择什么类型?
I have next arrays
NAMES1: array[0..1] of string = ('NO1','NAME1');
NAMES2: array[0..1] of string = ('NO2','NAME2');
and a record structure
TMyRec = record(
Name: ????;
);
As result I need to declare a constant array of records like following
const
StringArraysList: array[0..1] of TMyRec = (
(Name: NAMES1),
(Name: NAMES2)
);
The question is what type should I select for Name in TMyRec?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
你需要这样做:
你更愿意将最终声明写为
但这会导致
某些 Delphi 常量并不像您希望的那样常量!
记录常量的文档指出
类型化常量的文档指出
将这两个规则放在一起,我们就得到了
E2026
。You need to do it like this:
You would prefer to write the final declaration as
But that results in
Some Delphi constants are not as constant as you would like them to be!
The documentation for record constants states that
The documentation for typed constants states that
Put these two rules together and we have
E2026
.