![delphi – 为什么形式[…]的文字具有看似依赖于上下文的含义?,第1张 delphi – 为什么形式[…]的文字具有看似依赖于上下文的含义?,第1张](/aiimages/delphi+%E2%80%93+%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BD%A2%E5%BC%8F%5B%E2%80%A6%5D%E7%9A%84%E6%96%87%E5%AD%97%E5%85%B7%E6%9C%89%E7%9C%8B%E4%BC%BC%E4%BE%9D%E8%B5%96%E4%BA%8E%E4%B8%8A%E4%B8%8B%E6%96%87%E7%9A%84%E5%90%AB%E4%B9%89%EF%BC%9F.png)
{$APPTYPE CONSolE}type TMyEnum = (enum1,enum2,enum3);var Arr: TArray<TMyEnum>; Enum: TMyEnum;begin Arr := [enum3,enum1]; // <-- this is an array for Enum in Arr do Writeln(ord(Enum)); Writeln('---'); for Enum in [enum3,enum1] do // <-- this looks very much like the array above Writeln(ord(Enum)); Writeln('---'); Readln;end. 输出是:
20---02---
为什么两个循环产生不同的输出?
解决方法 因为数组包含订单信息而一组不包含订单信息.使用文档说明:
静态或动态数组的internal data format:
is stored as a contiguous sequence of elements of the component type of the array. The components with the lowest indexes are stored at the lowest memory addresses.
使用for循环is done in incremental order遍历这些索引:
The array is traversed in increasing order,starting at the lowest array bound and ending at the array size minus one.
另一方面,一套internal data format:
is a bit array where each bit indicates whether an element is in the set or not.
因此,所有这些“指示位”存储在一个相同的“值”中.这就是为什么一个集合可以是typecasted to an Integer type,以及为什么添加这些位的顺序丢失的原因:[enum3,enum1] = [enum1,enum3].
总结以上是内存溢出为你收集整理的delphi – 为什么形式[…]的文字具有看似依赖于上下文的含义?全部内容,希望文章能够帮你解决delphi – 为什么形式[…]的文字具有看似依赖于上下文的含义?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)