Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Delphi 7和_ArrayList_C#_Delphi_Com_Delphi 7 - Fatal编程技术网

C# Delphi 7和_ArrayList

C# Delphi 7和_ArrayList,c#,delphi,com,delphi-7,C#,Delphi,Com,Delphi 7,在Delphi 7中: 如何读取COM DLL中返回的数组列表​​在C#中 我试过这个: var products: IList; begin products := MyClass.Products() as IList; //... end; 文档中建议使用此模式,但在Delphi7中,我无法在我的products变量中应用for或while或其他任何变量 我的目的是阅读结果并将其存储在我的树视图中 我该怎么做 注意:IList源于mscorlib_TLB.pas,显然在Del

在Delphi 7中:

如何读取COM DLL中返回的数组列表​​在C#中

我试过这个:

var
  products: IList;
begin
  products := MyClass.Products() as IList;
  //...
end;
文档中建议使用此模式,但在Delphi7中,我无法在我的products变量中应用for或while或其他任何变量

我的目的是阅读结果并将其存储在我的树视图中

我该怎么做


注意:IList源于mscorlib_TLB.pas,显然在Delphi 7中,使用调用的
IList
IEnumerable
接口继承而来的
GetEnumerator
无法像Delphi的最新版本那样进行扫描或计数,获取一个
IEnumerator
接口并对其进行迭代。在伪代码中:

enumerator := products.GetEnumerator;
while enumerator.MoveNext do
  DoStuff(enumerator.Current);

我想您需要将
Current
转换为代码中更有用的内容。您可能还需要将
IList
转换为@TLama提到的
IEnumerable

Count
属性应该从接口继承,因此我认为
(Products as ICollection).Count
应该为您提供元素计数。其余部分可能与索引属性有关。我的意思是,为什么不回答这个问题?然后不需要PasteBin如果导入mscorlib类型库,您将看到
IList
IDispatch
继承了它。这就是为什么我建议将
作为
演员。好吧,这是伪代码。我想如果你想得到更多的帮助,你需要准确地解释你的代码是什么样子,以及“不工作”是什么意思。谢谢@DavidHeffernan先生。我知道这是一个伪代码。我正在阅读文档,并试图按照你的思路进行推理。