Click here to Skip to main content
15,896,063 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Generic Type and new() Pin
DaveyM6910-Oct-09 0:28
professionalDaveyM6910-Oct-09 0:28 
GeneralRe: Generic Type and new() Pin
Mycroft Holmes10-Oct-09 1:03
professionalMycroft Holmes10-Oct-09 1:03 
GeneralRe: Generic Type and new() Pin
Mycroft Holmes10-Oct-09 1:12
professionalMycroft Holmes10-Oct-09 1:12 
GeneralRe: Generic Type and new() Pin
Adam Maras10-Oct-09 3:05
Adam Maras10-Oct-09 3:05 
GeneralRe: Generic Type and new() Pin
Mycroft Holmes10-Oct-09 12:23
professionalMycroft Holmes10-Oct-09 12:23 
Questionmouse over form border event problem Pin
faith4ever4u9-Oct-09 12:05
faith4ever4u9-Oct-09 12:05 
AnswerRe: mouse over form border event problem Pin
Dave Kreskowiak9-Oct-09 12:21
mveDave Kreskowiak9-Oct-09 12:21 
Answerflame Pin
Luc Pattyn9-Oct-09 12:42
sitebuilderLuc Pattyn9-Oct-09 12:42 
QuestionHow to use C+++ ATL template calss in C# Pin
Chiman19-Oct-09 10:58
Chiman19-Oct-09 10:58 
AnswerRe: How to use C+++ ATL template calss in C# Pin
Dave Kreskowiak10-Oct-09 3:16
mveDave Kreskowiak10-Oct-09 3:16 
QuestionInvoking Progressbar Pin
SimpleData9-Oct-09 10:11
SimpleData9-Oct-09 10:11 
AnswerRe: Invoking Progressbar Pin
Luc Pattyn9-Oct-09 10:13
sitebuilderLuc Pattyn9-Oct-09 10:13 
GeneralRe: Invoking Progressbar Pin
SimpleData9-Oct-09 10:49
SimpleData9-Oct-09 10:49 
GeneralRe: Invoking Progressbar Pin
Luc Pattyn9-Oct-09 10:56
sitebuilderLuc Pattyn9-Oct-09 10:56 

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.