Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generic list question
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Generic list question
Versions des environnements
Environment:
C# 5.0
OS:
Windows 7
Network:
SAMBA Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01611163
Message ID:
01611163
Vues:
91
Hi All, I need to declare a generic list of a type which is decided at runtime, the type is one of several classes that all implement a common interface , I'm unsure how to do this, at first I thought I could use the Type of the class to create a list but this is not so - a small example of what I mean is shown below
IMyInterFace  i = GetClassType();

List<i> mylist = new List<i>();


IMyInterFace GetClassType()
{
  if(SomeCondition)
    return ClassA;
  else
    return classB;
}
Regards,
Peter J. Kane



Pete
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform