And*_*are 16
GvS是正确的 - 这是一个用法的例子:
using System;
using System.Reflection;
class Program
{
static void Main()
{
Type type = Type.GetType("Foo");
MethodInfo info = type.GetMethod("Bar");
Console.WriteLine(info.Invoke(null, null));
}
}
static class Foo
{
public static String Bar() { return "Bar"; }
}
Run Code Online (Sandbox Code Playgroud)
小智 6
使用MethodInfo.Invoke的另一个示例
Type myStaticClassType = Type.GetType("MyStaticClassNameSpace",true);
object[] myStaticMethodArguments = {object1,object2...};
MethodInfo myStaticMethodInfo = myStaticClassType.GetMethod("YourMethod");
var myStaticMethodResult = myStaticMethodInfo.Invoke(null,myStaticMethodArguments);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8159 次 |
| 最近记录: |