This for C#? Passing Class type as a parameter
I have a class adapter that implements an Interface. I want to fill an array structure with MyFooClass instances where M
Generics and their constraints should do what you want, I believe:
public void FillWsvcStructs(DataSet ds) where ClassType : IElemRequest, new()
{
IFoo.Request = ds.DataTable[0].Request;
IFoo.Modulebq = string.Empty;
IFoo.Clasific = string.Empty;
IFoo.Asignadoa = ds.DataTable[0].Referer;
IFoo.Solicita = "Jean Paul Goitier";
// Go with sub-Elems (Also "Interfaceated")
foreach (DataSet.DataTableRow ar in ds.DataTable[1])
{
if ((int) ar.StatusOT != (int)Props.StatusOT.NotOT)
{
IElemRequest req = new ClassType();
req.Id = string.Empty;
req.Type = string.Empty;
req.Num = string.Empty;
req.Message = string.Empty;
req.Trkorr = ar[1];
TRequest.Add(req);
}
}
}