23 August, 2011
0 Comments
1 category
http://elegantcode.com/2010/01/28/calling-non-public-methods/
// Calling code that uses delegates
var subject = new Subject();
var doSomething = (Func<String, String>)
Delegate.CreateDelegate(typeof(Func<String, String>), subject, "DoSomething");
Console.WriteLine(doSomething("Hello Freggles"));
Note that this only works for instance methods and not for static methods.
Tags: C#
Category: Uncategorized