mercredi 20 février 2019

C# convert string to type argument [duplicate]

This question already has an answer here:

public ActionResult Customer(string fullNameSpace)
{
    var genType = fullNameSpace.ToGenericType(); //how can I do this?
    var clList = _adminService.GetCustomerList<genType>(23);
    return PartialView(clList);
}


public IEnumerable<CustomerVM> GetCustomerList<S>(int clientId) where S : IEntityVMSortOrder{
    ...
}

Without changing the GetCustomerList function, how can I produce genType from the passed string argument? If this is possible at all.





Aucun commentaire:

Enregistrer un commentaire