我正在使用“混合模式”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;
}