Skip to content

Instantly share code, notes, and snippets.

@plioi
Created December 13, 2013 14:14
Show Gist options
  • Save plioi/7944850 to your computer and use it in GitHub Desktop.
Save plioi/7944850 to your computer and use it in GitHub Desktop.
var instance = new Thing();
var method = typeof(Thing).GetMethod("GenericMethod");
var methodOfInt32 = method.MakeGenericMethod(typeof(int));
methodOfInt32.Invoke(instance, new object[] { 1 });
var methodOfBoolean = method.MakeGenericMethod(typeof(bool));
methodOfBoolean.Invoke(instance, new object[] { true });
var methodOfString = method.MakeGenericMethod(typeof(string));
methodOfString.Invoke(instance, new object[] { "Cantaloupe Pantaloons" });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment