I have a class (that I cannot modify) that simplifies to this:
public class Foo {
public static string MyProperty {
get {return \"Metho
The method is static, so you don't need an instance of an object. You could directly invoke it:
public class Foo
{
public static string MyMethod()
{
return "Method: " + typeof(T).ToString();
}
}
class Program
{
static void Main()
{
Type myType = typeof(string);
var fooType = typeof(Foo<>).MakeGenericType(myType);
var myMethod = fooType.GetMethod("MyMethod", BindingFlags.Static | BindingFlags.Public);
var result = (string)myMethod.Invoke(null, null);
Console.WriteLine(result);
}
}