这适用于 C#? 传递类类型作为参数
我有一个实现接口的类适配器。我想用 MyFooClass 实例填充数组结构,我想从外部接收 MyFooClass 的名称或引用。我将在我的适配器代码中实例化它们。
例如:
public void FillWsvcStructs(DataSet ds, ClassType Baz)
{
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)
{
///From HERE!
IElemRequest req = new (Baz)(); // I don't know how to do it here
///To HERE!
req.Id = string.Empty;
req.Type = string.Empty;
req.Num = string.Empty;
req.Message = string.Empty;
req.Trkorr = ar[1];
TRequest.Add(req);
}
}
}