Je souhaite effectuer un transtypage explicite à l'aide des informations de type d'un tableau à un autre lié par héritage. Mon problème est que lors de la diffusion à l'aide d'informations de type, le compilateur génère une erreur, mais mon exigence est de lancer dynamiquement en fonction des informations de type fournies.Coulée dynamique basée sur les informations de type
S'il vous plaît Aide
class Program
{
static void Main(string[] args)
{
Parent[] objParent;
Child[] objChild = new Child[] { new Child(), new Child() };
Type TypParent = typeof(Parent);
//Works when i mention the class name
objParent = (Parent[])objChild;
//Doesn't work if I mention Type info
objParent = (TypParent[])objChild;
}
}
class Parent
{
}
class Child : Parent
{
}