Click here to Skip to main content
15,905,136 members
Home / Discussions / C#
   

C#

 
AnswerRe: progress bar Pin
DaveyM6910-Oct-09 0:17
professionalDaveyM6910-Oct-09 0:17 
GeneralRe: progress bar Pin
Member 59031010-Oct-09 2:01
Member 59031010-Oct-09 2:01 
GeneralRe: progress bar Pin
DaveyM6910-Oct-09 3:18
professionalDaveyM6910-Oct-09 3:18 
QuestionOpen Ms Access Reports in Win Form Pin
Abdul Rahman Hamidy9-Oct-09 23:41
Abdul Rahman Hamidy9-Oct-09 23:41 
AnswerRe: Open Ms Access Reports in Win Form Pin
Dave Kreskowiak10-Oct-09 3:14
mveDave Kreskowiak10-Oct-09 3:14 
AnswerRe: Open Ms Access Reports in Win Form Pin
Md. Marufuzzaman10-Oct-09 3:43
professionalMd. Marufuzzaman10-Oct-09 3:43 
Questionreading bios information in c# Pin
Fred 349-Oct-09 23:38
Fred 349-Oct-09 23:38 
AnswerRe: reading bios information in c# Pin
stancrm10-Oct-09 1:00
stancrm10-Oct-09 1:00 
GeneralRe: reading bios information in c# Pin
Fred 3410-Oct-09 9:14
Fred 3410-Oct-09 9:14 
AnswerRe: reading bios information in c# Pin
Richard MacCutchan10-Oct-09 2:42
mveRichard MacCutchan10-Oct-09 2:42 
GeneralRe: reading bios information in c# Pin
Fred 3410-Oct-09 9:12
Fred 3410-Oct-09 9:12 
GeneralRe: reading bios information in c# Pin
Richard MacCutchan10-Oct-09 21:27
mveRichard MacCutchan10-Oct-09 21:27 
QuestionDataGrid Pin
Yonathan11119-Oct-09 22:29
professionalYonathan11119-Oct-09 22:29 
AnswerRe: DataGrid Pin
Suresh Suthar9-Oct-09 22:40
professionalSuresh Suthar9-Oct-09 22:40 
Questionwindow above everything else including taskbar + start-button? Pin
FocusedWolf9-Oct-09 20:08
FocusedWolf9-Oct-09 20:08 
AnswerRe: window above everything else including taskbar + start-button? [modified] Pin
FocusedWolf11-Oct-09 17:47
FocusedWolf11-Oct-09 17:47 
QuestionAuto generate numbers in listview? Pin
avirag9-Oct-09 18:55
avirag9-Oct-09 18:55 
AnswerRe: Auto generate numbers in listview? Pin
OriginalGriff9-Oct-09 22:24
mveOriginalGriff9-Oct-09 22:24 
GeneralRe: Auto generate numbers in listview? Pin
avirag11-Oct-09 18:56
avirag11-Oct-09 18:56 
QuestionMonitoring idle time while Minimized using MFC Pin
Daniel Kamisnki9-Oct-09 16:53
Daniel Kamisnki9-Oct-09 16:53 
AnswerRe: Monitoring idle time while Minimized using MFC Pin
stancrm9-Oct-09 17:25
stancrm9-Oct-09 17:25 
QuestionGeneric Type and new() Pin
Mycroft Holmes9-Oct-09 16:21
professionalMycroft Holmes9-Oct-09 16:21 
I am trying to put to gether a BaseTable helper class. This class is expected to be inherited by the TableClass (each table in the database has a class)

I have the feeling I may have the wrong handle on this but here goes:

T is the table class and oTable is the datatable with the rows I want to turn into a List<> of T

RowToObject<T>(oClass1, oTable);
This takes an empty copy of the TableClass and loads the datarow in, works well

My problem is trying to create a new instance of oClass

public List<T> ToList<T>(T oClass, DataTable oTable)
{
    try
    {
        Type t = oClass.GetType();
        List<T> ClassList = new List<T>();

        foreach (DataRow oRow in oTable.Rows)
        {
            T oClass1 = new T();//  THIS IS NOT CORRECT
            RowToObject<T>(oClass1, oTable);
            ClassList.Add(oClass1);
        }
        return ClassList;
    }
    catch (Exception)
    { throw; }
}


I get the following compile error that wants a new() constraint on T but this helper class should not know who is using it, indicating I am screwing it up.
Cannot create an instance of the variable type 'T' because it does not have the new() constraint


Enlightenment would be appreciated!

Never underestimate the power of human stupidity
RAH

AnswerRe: Generic Type and new() Pin
Adam Maras9-Oct-09 20:27
Adam Maras9-Oct-09 20:27 
GeneralRe: Generic Type and new() Pin
Mycroft Holmes9-Oct-09 21:29
professionalMycroft Holmes9-Oct-09 21:29 
GeneralRe: Generic Type and new() Pin
Mirko198010-Oct-09 0:24
Mirko198010-Oct-09 0:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.