void say(string param)
{
Console.WriteLine(param);
}
Action name = () => say("привет");
name();
Через делегат: public delegate void Callback(string param);
void say(string param)
{
Console.WriteLine(param);
}
Callback name = say;
name("привет");
using System;
using System.Reflection;
public class HelloWorld
{
public void say()
{
Console.WriteLine("Hello");
}
public static void Main(string[] args)
{
Type thisType = Type.GetType("HelloWorld");
ConstructorInfo thisCtr = thisType.GetConstructor(Type.EmptyTypes);
object thisExample = thisCtr.Invoke(new object[] { });
MethodInfo sayMethod = thisType.GetMethod("say");
if (sayMethod != null)
{
sayMethod.Invoke(thisExample, null);
}
else
{
Console.WriteLine("Cannot find method say()!!!");
}
}
}