您的位置:首页 > 编程语言 > C#

C#中反射调用带out参数的方法

2007-11-09 14:31 459 查看
using System;

using System.Reflection;

namespace ConsoleApplication1

{

public class TestAssembly

{

public TestAssembly()

{

String str = "aa";

object[] parmsObj = new object[] { str };

Assembly assembly = Assembly.GetExecutingAssembly();

Type actionType = assembly.GetType("ConsoleApplication1.TestClass");

MethodInfo method = tp.GetMethod("test", new Type[] { Type.GetType("System.String&") });

object obj = Activator.CreateInstance(actionType.FullName);

method.Invoke(obj, parmsObj);

Console.WriteLine(parmsObj[0]);

}

}

public class TestClass

{

public void test(out string str)

{

str = "test1";

}

public void test(string str)

{

str = "test2";

}

}

}

链接资源: http://support.microsoft.com/default.aspx?scid=kb%3bzh-cn%3b815211
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐