Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.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
如何从matlab修改c#.NET字典_C#_.net_Matlab_Dictionary - Fatal编程技术网

如何从matlab修改c#.NET字典

如何从matlab修改c#.NET字典,c#,.net,matlab,dictionary,C#,.net,Matlab,Dictionary,假设我有以下C#类 其中LoadDotNetAssembly是Matlab的NET.addAssembly()函数的方便包装器。我可以使用以下方法从字典的实例中读取值 q.D.Item('A') 但是,我无法使用设置特定字典项的值 q.D.Item('A') = 'foo' Array formation and indexing are not allowed on .NET objects. 修改c#.NET字典项的正确语法是什么?按索引设置列表中值的官方方法 我目前手头没有Matlab

假设我有以下C#类

其中LoadDotNetAssembly是Matlab的NET.addAssembly()函数的方便包装器。我可以使用以下方法从字典的实例中读取值

q.D.Item('A')
但是,我无法使用设置特定字典项的值

q.D.Item('A') = 'foo'
Array formation and indexing are not allowed on .NET objects.

修改c#.NET字典项的正确语法是什么?

按索引设置
列表中值的官方方法

我目前手头没有Matlab,但这有可能直接转化为
字典


是的,q.D.Item('A')编译并给出字典中“A”键的值,即“myA”。您必须记住,q.D.Item('A')是从Matlab调用的,其中“A”是stringDoes
q.D['A']='foo'
work?或者
q.D('A')=“foo”
?您能否使用
删除
然后
添加
?这两种方法都不起作用,会出现各种错误。移除然后添加是一种可能性,但当所需的只是一个回形针时,就好像使用锤子一样↑ 错误:不平衡或意外的括号或括号。>>q、 在.NET对象上不允许D('A')='foo'数组的形成和索引。
q.D.Item('A')
q.D.Item('A') = 'foo'
Array formation and indexing are not allowed on .NET objects.
D.Item('A', 'foo')