mardi 20 janvier 2015

Calling empty default constructor of type

I'm trying to instantiate every property (of type JobVmInput) on my object. This is my code so far:



var properties = this.GetType().GetProperties();

foreach (var p in properties)
{
var type = p.PropertyType;
if (type.IsSubclassOf(typeof(JobVmInput)))
{
var constructor = type.cons.GetConstructor(**what to input here**);
p.SetValue(p, constructor.Invoke(**what to input here**));
}
}


However I don't know what to input in the GetConstructor and constructor.Invoke methods. I've looked at the MSDN documentation but I'm quite uncertain in regards to what they accept. I just want to call the empty default constructor.






Aucun commentaire:

Enregistrer un commentaire