Let's just say that some other code in some other file already does the following:
SomeVehicleType = typeof(Car);
which is located in some other file.
Now, using the Type SomeVehicleType in the current code file that I'm implementing, I have the following code:
public int SomeBlahMethod(Type SomeVehicleType)
{
dynamic actualSomeVehicleTypeInstance = Activator.CreateInstance(SomeVehicleType);
List<actualSomeVehicleTypeInstance.GetType()> blahVehicleList = new List<actualSomeVehicleTypeInstance.GetType()>();
// Or even the following line of code
List<typeof(actualSomeVehicleTypeInstance)> blahVehicleListSecond = new List<typeof(actualSomeVehicleTypeInstance)>();
}
Both the aforementioned lines throw a bunch of syntax errors
Basically, how can I implement code that parameterize or even instantiate what an actual C# Type variable actually refers to?
Aucun commentaire:
Enregistrer un commentaire