Skip to content

Instantly share code, notes, and snippets.

@Jalalx
Last active May 27, 2016 03:46
Show Gist options
  • Save Jalalx/0a1f321a9c514217e08e130c7a4b5871 to your computer and use it in GitHub Desktop.
Save Jalalx/0a1f321a9c514217e08e130c7a4b5871 to your computer and use it in GitHub Desktop.
Calling member method of a normal class without instantiating.
public class Foo
{
public void Method1()
{
Console.WriteLine("Method1: this == null: {0}", this == null);
}
}
var m1 = typeof(Foo).GetMethod("Method1");
var method1 = Delegate.CreateDelegate(typeof(Action<Foo>), m1) as Action<Foo>;
method1(null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment