NET 实例化泛形对象并赋值
程序员文章站
2022-08-05 21:47:19
1.泛形方法:具体实例点击查看BuilderResultList 2.调用 ......
1.泛形方法:具体实例点击查看builderresultlist
/// <summary> /// 实例化泛形对象并赋值 /// </summary> /// <typeparam name="t"></typeparam> /// <param name="entity"></param> private static void builder<t>(t entity) where t : class, new() { t newentity = new t(); var newentitytype = newentity.gettype(); newentitytype.getproperty("属性名").setvalue(newentity, "属性值"); }
2.调用
builder(new userdto());
下一篇: 采用layui技术制作精美表格案例