public static void Main()
var vehicleString = "Car";
var vehicleType = Type.GetType(vehicleString);
Console.WriteLine("Type from string: " + vehicleType);
typeof(MyFactory).GetMethod("Register")
.MakeGenericMethod(vehicleType)
typeof(MyFactory).GetMethod("RegisterWithParameter")
.MakeGenericMethod(vehicleType)
.Invoke(null, new object[] {carId});
public static void Register<T>()
Console.WriteLine($"Generic type parameter: {typeof(T)}");
public static void RegisterWithParameter<T>(int carId)
Console.WriteLine($"Generic type parameter: {typeof(T)} || Method parameter: carId={carId}");