Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generic list question
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
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:
01611169
Vues:
52
>Hi Gregory and thanks, I should have been clearer, I don't want an instance of the class I need its type , what I need to do is get a List(T) from a Generic(T) class , the generic class expects a class of type IMyInterFace to create and populate a List(T) I show a code snippet below
>
>
>I create it like this at the moment
>
>if(some condition)
>    XLToList(MyClass) xlist = new XLToList(MyClass)();
>else
>    XLToList(MyOtherClass) xlist2 = new XLToList(MyOtherClass)();
>
>
>public class XlToList(T) where T : ITariffDataImport, new()
>    {
>        public delegate void Notify(object sender, CSVEventargs e);
>        public delegate void NotifyEveryRecord(int RecordNumber);
>        public event Notify OnFinishedProcessing;
>        public event Notify OnFoundBadTariff;
>        public event Notify OnFoundStartingRow;
>        public event NotifyEveryRecord OnProcessingRecords;
>
>
>        private Type thistype = typeof(T);
>
>        private List(T) data;
>
>        public List(T) Data
>        {
>            get
>            {
>                return data;
>            }
>            set
>            {
>                data = value;
>            }
>        }
>
>
>and the class uses T to create types and class instances etc... any clearer ? ( sorry I've used parentheses instead of angle brackets because of the UT limitations.)

Maybe you need to use MakeGenericType : http://msdn.microsoft.com/en-us/library/system.type.makegenerictype(v=vs.110).aspx
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform