当我传递 PHP 索引数组时:
$myVar = new COM('MyClass');
$myVar->DubbleArray([1, 2]);
...它作为 System.Object[] 传递给 C# 或 F#,我可以相应地处理它,例如:
[<ComVisible(true)>]
type LettersClass() =
member this.DubbleArray(array: obj[]) =
// do stuff with the values in the array
但是当我传递关联数组时:
$myVar->DubbleArray(array('first'=>'1st','second'=>'2nd'));
...它以 DBNull 的形式出现。
有没有办法通过 COM 将关联数组传递给 .NET 函数?
最佳答案
使用 Dictionary .NET 中允许您处理命名键。您始终可以以 JSON 格式对数据进行编码,然后也可以在 .NET 中进行解码...:)
(注意:这个答案是基于在您的问题中没有看到任何 .net)
关于c# - 我可以将 PHP 关联数组传递给 ComVisible .NET 函数吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40940104/