C#如何用函数名字符串来调用函数 C#如何用函数名字符串来调用函数?除了委托以外,还有什么办法没有? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 反射我晓得就没有现成的函数么Process(“name”)这么简单的 //加载程序集 Assembly s = Assembly.Load("RecleTest"); Type tpe = s.GetType("RecleTest.Car"); //调用GetName方法 MethodInfo method = tpe.GetMethod("GetName"); //获取需要传入的参数 ParameterInfo[] parms = method.GetParameters(); //这里是判断参数类型 foreach (ParameterInfo ss in parms) { if (ss.ParameterType == typeof(string)) { Console.WriteLine("Yes"); } } //获取Car对象 object obj = s.CreateInstance("RecleTest.Car"); //如果有返回值接收下 method.Invoke(obj, new object[] { "小小" }); Console.ReadLine(); string returnValue1 = classSampleType.InvokeMember("ClassMethod", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, null, new object[] { }) as string;MethodInfo method0 = (MethodInfo)(new StackTrace().GetFrame(0).GetMethod());http://topic.csdn.net/u/20090408/17/3925e17c-241c-401d-a9f2-1eb834cff12f.html 熟悉进销存的高手请帮帮忙,谢谢 关于窗体调用的问题 c#做的C/S应用程序如何建立操作日志? C# 扫描 进度条 用WebClient下载文件路径出现非法字符 C# SOCKET TCP发送多个文件问题 关于PreviousPage.FindControl的疑问! 委托和范型,在C#中如何应用?还有,哪有这方面的资料? 一个winform程序在intranet运行的问题 一个字符串的问题 this关键字常用的一个功能是把一个当前对象实例的引用传递给一个方法 C#写个小程序检测计算机是否安装Framework
就没有现成的函数么
Process(“name”)这么简单的
//加载程序集
Assembly s = Assembly.Load("RecleTest");
Type tpe = s.GetType("RecleTest.Car"); //调用GetName方法
MethodInfo method = tpe.GetMethod("GetName"); //获取需要传入的参数
ParameterInfo[] parms = method.GetParameters(); //这里是判断参数类型
foreach (ParameterInfo ss in parms)
{
if (ss.ParameterType == typeof(string))
{
Console.WriteLine("Yes");
}
} //获取Car对象
object obj = s.CreateInstance("RecleTest.Car"); //如果有返回值接收下
method.Invoke(obj, new object[] { "小小" }); Console.ReadLine();
MethodInfo method0 = (MethodInfo)(new StackTrace().GetFrame(0).GetMethod());
http://topic.csdn.net/u/20090408/17/3925e17c-241c-401d-a9f2-1eb834cff12f.html