[英]I am trying to call InvokeMethod for any method which arguments accept some Ref parameters it is giving exceptions
我想知道如何在使用InvokeMember調用該方法時將參數傳遞給ref / out。
我正在嘗試為參數接受某些Ref參數的任何方法調用InvokeMethod,它給出了異常。
與ref和out修飾符一起使用。
public class Example {
public static void Foo(ref string name) {
name = "foo";
}
public static void Test() {
var p = new object[1];
var info = typeof(Example).GetMethod("Foo");
info.Invoke(null, p);
var returned = (string)(p[0]); // will be "foo"
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.