I'm trying to understand delegations so I just wrote small try project; I have class D:
class D
{
private static void Func1(Object o)
{
if (!(o is string)) return;
string s = o as string;
Console.WriteLine("Func1 going to sleep");
Thread.Sleep(1500);
Console.WriteLine("Func1: " + s);
}
}
and in the main im using:
MethodInfo inf = typeof(D).GetMethod("Func1", BindingFlags.NonPublic | BindingFlags.Static);
Delegate d = Delegate.CreateDelegate(typeof(D), inf);
The method info gets the correct info but the CreateDelegate method throws an exception, saybg that the type must derive from Delegate.
How can i solve this?