I have the following class (with private .ctor and a public factory method)
public class TypeWithFactoryMethods
{
private TypeWithFactoryMethods()
{
}
public static TypeWithFactoryMethods Create()
{
return new TypeWithFactoryMethods();
}
}
What is the best way to invoke the public factory method (Create) via reflection so I can get an instance of the type?
Not quite sure what the goal is, but this would do it:
Update after comment
If you want to find all methods that return your specified type you can use Linq to find them: