フィルターのクリア

How to call a .net function that uses a params parameter?

1 回表示 (過去 30 日間)
kent archie
kent archie 2015 年 4 月 15 日
編集済み: Matthew 2018 年 6 月 18 日
I have a C# function in a dll that has this signature
public static double Invoke(string desk, string functionName, params string[] arguments)
I can include the assembly in Matlab, but when I call the function like this:
cls.Invoke('string1', 'string2', 'params1', 'params2', 'params3', 'params4')
I get this error No method 'Invoke' with matching signature found for class 'cls' Using the example code here http://www.mathworks.com/help/matlab/matlab_external/call-net-methods-with-params-keyword.html I made an array of strings and passed that in place of the params1-4 above with the same results. I can call other methods in the C# code that have a fixed number of arguments. I'm missing something and would appreciate any suggestions

回答 (1 件)

Matthew
Matthew 2018 年 6 月 18 日
編集済み: Matthew 2018 年 6 月 18 日
The provided example for that uses integers, so its a bit confusing when applying that example to strings.
I was able to use string params by passing in a cell array of character vectors.
i.e. if the c# method was
public static double Invoke(string desk, string functionName, params string[] arguments)
I was able to call it as
cls.Invoke('string1', 'string2', {'params1', 'params2', 'params3', 'params4'})

カテゴリ

Help Center および File Exchange.NET Methods in MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by