0

我正在使用“混合模式”c++ 并调用我无法控制的 ac# dll 中的函数。我的所有调用都在 ac# test exe 中工作,但我无法将返回数组的调用转换为混合模式 c++。我不需要在 C++ 中修改数组,只需阅读它。

我有 2 个在 c# 中工作的选项,让任何一个在 c++ 中工作就足够了。

这是从 c# dll 获取数组的基本 c# exe 调用

CoefficientGroup[] G = Cfg.GetCoefficientGroups();

在我的 C++ 中,我尝试了许多带有 ^ 的选项,但无济于事 - 它不会编译

CoefficientGroup^[] G = Cfg->GetCoefficientGroups(); etc etc

我也在 c# 中尝试过这种方法,效果很好

System.Collections.IEnumerator eG = Cfg.GetCoefficientGroups().GetEnumerator();
while (eG.MoveNext())
{
      CoefficientGroup X = eG.Current as CoefficientGroup;
}

但在 c++ 中,我无法找到可以编译的 c++ 中的“as”强制转换 - 如下所示

System::Collections::IEnumerator^ eG = Cfg->GetCoefficientGroups()->GetEnumerator();
while (eG->MoveNext())
{
    CoefficientGroup^ X = (CoefficientGroup)eG->Current;
}
4

1 回答 1

0

好的,我自己找到了一个答案。我错过了这个演员 CoefficientGroup^ X = (CoefficientGroup^)eG->Current; 的帽子。仍然对数组声明的答案感兴趣

于 2013-11-09T18:55:32.737 回答