Matlab Read a System.Col​lections.G​eneric.Dic​tionary from c# dll

13 ビュー (過去 30 日間)
Maria Isabel
Maria Isabel 2013 年 1 月 13 日
コメント済み: Radhakrishnan 2018 年 10 月 26 日
I have a Matlab application and I receive from a c# dll (NET Assembly) a
System.Collections.Generic.Dictionary*KeyCollection<System*String,System*Collections*Generic*List<System*Double>>
I would like to fill a containers.map with the received info: Keys/ Values
How can I read this kind of Collection in Matlab?
Thank u for support
  2 件のコメント
Doctor G
Doctor G 2016 年 4 月 1 日
編集済み: Doctor G 2016 年 4 月 1 日
If you use methods(dictObj) you will see that the dictObject supports the .Item() and other methods.
Add GetObjectData
Clear GetType
ContainsKey Item
ContainsValue OnDeserialization
Dictionary<System*String,System*Object> Remove
Equals ToString
GetEnumerator TryGetValue
GetHashCode
Radhakrishnan
Radhakrishnan 2018 年 10 月 26 日
Any Idea how to create the above collection in Matlab? I tried the following but none is working ; c1,c2,c3 are failing
DoubleListType = NET.GenericClass('System.Collections.Generic.List','System.Double'); DictType = NET.GenericClass('System.Collections.Generic.Dictionary','System.String',{DoubleListType}); c3 = NET.createGeneric('System.Collections.Generic.Dictionary','System.String',NET.GenericClass('System.Collections.Generic.List','System.Double'));
c2 = NET.createGeneric({DictType}); c1 = NET.createGeneric('System.Collections.Generic.Dictionary','System.String',{DoubleListType});

サインインしてコメントする。

回答 (1 件)

Darren Aklestad
Darren Aklestad 2013 年 5 月 31 日
I was able to do this by the following:
keys = dic.Keys;
keys_enum = keys.GetEnumerator;
len = dic.Count;
key_list = cell(len,1);
cnt = 0;
stat = 1;
while stat
stat = key_enum.MoveNext;
if stat
key_val = key_enum.Current;
if ~isempty(key_val)
key_list(cnt) = char(key_val);
end
end
end
You then have the keys and you can use the keys to access the dictionary items

カテゴリ

Help Center および File ExchangeVariables についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by