Delegate.CreateDelegate 使用

    class Program
    {
        static void Main(string[] args)
        {
							var res = Delegate.CreateDelegate(typeof(Action<string, string>), typeof(Person).GetMethod("GetName"));
            res.DynamicInvoke("test1", "test2");
            Console.Read();
        }
    }
    public class Person
    {
        public static void GetName(string first, string second)
        {
            Console.WriteLine("test");
        }
    }

作者:spike

分类: Net

创作时间:2023-06-25

更新时间:2024-12-09

联系方式放在中括号之中例如[[email protected]],回复评论在开头加上标号例如:#1