真爱无限的知识驿站

学习积累技术经验,提升自身能力

c#利用反射,实现将model类变成字符串、再还原成mode对象的功能

处理类:

public string ToString(UserGiftCardModel model)
        {
            if (model == null) return "";
            string sb = "";
            Type type =model.GetType() ;//assembly.GetType("Reflect_test.PurchaseOrderHeadManageModel", true, true); //命名空间名称 + 类名  
            //创建类的实例  
            //object obj = Activator.CreateInstance(type, true);
            //获取公共属性  
            PropertyInfo[] Propertys = type.GetProperties();


<< 1 >>

Powered By Z-BlogPHP 1.7.3

Copyright 2024-2027 pukuimin Rights Reserved.
粤ICP备17100155号