public static string getPro(object model,string modelType){}
此方法的参数,model,因方法的重用,可能是很多种类型的model,
再传一个string的参数过来,这个modelType是传过来的model的类型,怎么能把model转换成modelType的类型对象呢?在线等待呀,都来帮帮忙....
此方法的参数,model,因方法的重用,可能是很多种类型的model,
再传一个string的参数过来,这个modelType是传过来的model的类型,怎么能把model转换成modelType的类型对象呢?在线等待呀,都来帮帮忙....
public static string getPro<ModelType>(ModelType model){}
然后用反射动态创建一个实例 Activator.CreateInstance(XX);
楼主的思路有问题吧?假设有3个类,A,B,C
你的代码想怎么写?除非这些类有共同的基类或接口,否则你的函数里边写什么?
你反射回来也是Object,也需要转换成实际的类型才能调用方法或属性吧!
可是,你在写方法的时候能知道有哪些类型会被传进来吗?