F
Frank Rizzo
I am trying to create a parametrized generic object, but the compiler won't
let me. Is this just the way it is? The class has a constraint that says
all classes must inherit from BusinessBase, which specifies a parametrized
constructor. But c# won't let me do it.
public class DataHelper<T> where T : BusinessBase, new()
{
public static List<T> DataTableToList(DataTable dataTable)
{
List<T> listOfItems = new List<T>();
foreach (DataRow dr in dataTable.Rows)
{
T recipient = new T(dr); // **** causes an error ****
listOfItems.Add(recipient);
}
return listOfItems;
}
}
let me. Is this just the way it is? The class has a constraint that says
all classes must inherit from BusinessBase, which specifies a parametrized
constructor. But c# won't let me do it.
public class DataHelper<T> where T : BusinessBase, new()
{
public static List<T> DataTableToList(DataTable dataTable)
{
List<T> listOfItems = new List<T>();
foreach (DataRow dr in dataTable.Rows)
{
T recipient = new T(dr); // **** causes an error ****
listOfItems.Add(recipient);
}
return listOfItems;
}
}