将C#映射集合传递给Axapta代码

将C#映射集合传递给Axapta代码,c#,.net,axapta,x++,dynamics-ax-2009,C#,.net,Axapta,X++,Dynamics Ax 2009,我有一个C#类和返回字典的方法。我可以在Axapta中创建这个类的实例,调用这个方法并将集合返回给Axapta,但是我不能迭代这个集合并获取它的键和值 以下是我的Axapta代码: ClrObject obj; ; obj = document.findText("some"); // returns Dictionary<string, string> length = obj.get_Count(); // returns 5 (fine!) obj.MoveNext(); /

我有一个C#类和返回字典的方法。我可以在Axapta中创建这个类的实例,调用这个方法并将集合返回给Axapta,但是我不能迭代这个集合并获取它的键和值

以下是我的Axapta代码:

ClrObject  obj;
;
obj = document.findText("some"); // returns Dictionary<string, string>
length = obj.get_Count(); // returns 5 (fine!)
obj.MoveNext(); // doesn't works 

for (i = 0; i < length; i++ )
{
   obj.get_Key(i);  // doesn't work
}
clrobjectobj;
;
obj=document.findText(“some”);//返回字典
length=obj.get_Count();//返回5(好!)
obj.MoveNext();//不起作用
对于(i=0;i

在Axapta中迭代字典是一种方法吗?

字典上既没有
get\u Key
也没有
MoveNext
方法

必须对枚举器调用
MoveNext
。也就是说,您可以通过调用字典上的
GetEnumerator
来检索一个,然后使用它:

System.Collections.Specialized.StringDictionary dotNetStringDict;
System.Collections.IEnumerator dotNetEnumerator;
System.Collections.DictionaryEntry dotNetDictEntry;
str tempValue;
;

dotNetStringDict = new System.Collections.Specialized.StringDictionary();
dotNetStringDict.Add("Key_1", "Value_1");
dotNetStringDict.Add("Key_2", "Value_2");
dotNetStringDict.Add("Key_3", "Value_3");

dotNetEnumerator = dotNetStringDict.GetEnumerator();
while (dotNetEnumerator.MoveNext())
{
    dotNetDictEntry = dotNetEnumerator.get_Current();
    tempValue = dotNetDictEntry.get_Value();
    info(tempValue);
}