Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generic list question
Message
 
To
19/11/2014 07:49:21
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 5.0
OS:
Windows 7
Network:
SAMBA Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01611163
Message ID:
01611167
Views:
64
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.)

Thanks again Greg
Regards,
Peter J. Kane



Pete
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform