0 Comments

 

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts