惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
C
Check Point Blog
B
Blog RSS Feed
G
Google Developers Blog
H
Help Net Security
博客园 - Franky
Blog — PlanetScale
Blog — PlanetScale
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Recent Announcements
Recent Announcements
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
DataBreaches.Net
小众软件
小众软件
T
The Blog of Author Tim Ferriss
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
Y
Y Combinator Blog
T
Tailwind CSS Blog
J
Java Code Geeks
MyScale Blog
MyScale Blog
雷峰网
雷峰网
有赞技术团队
有赞技术团队
博客园 - 聂微东

博客园 - 踏踏实实干

asp.net MVC4 框架揭秘 读书笔记系列3 asp.net MVC4 框架揭秘 读书笔记系列2 asp.net MVC4 框架揭秘 读书笔记系列1 什么?你还不会写JQuery 插件 jQuery命名空间,插件开发 微信开发资源 jstree 从简单说起Jquery 插件应用说明 sync framework参考收集系列 收集一些.net 组件开发资源 (转) c# 调用SQL Server存储过程返回值(转) C#事务 访问数据库(转) 多库查询 sp_addlinkedserver使用方法(添加链接服务器)(转)片段整理 asp.net 动态数据网站简单应用,快速建立站点实现对库方便的增删改 利用asp.net路由实现url解析 智能客户端(Smart Client )中文文档及案例(转贴) 男人30而立,30岁的男人喊起来!你们立了吗? jquery 实现从左边listbox选择至右边listbox asp.net 造成seesion 丢失的问题之一 转摘 JQUERY操作JSON例子
利用反射对对象属性赋值取值操作
踏踏实实干 · 2012-02-07 · via 博客园 - 踏踏实实干

零碎的东西 收藏整理

 取值

typeof(T).GetProperty("FieldName").GetValue(model.Uploaddata[j], null);

还是用这个方法来诠释吧

    

public static void Assign<T>(T objSource, T objDest)
    {
        PropertyInfo[] property = typeof(T).GetProperties();
        foreach (PropertyInfo p in property)
        {
            Type t = p.PropertyType;
            if (t == typeof(String) || t == typeof(int) || t == typeof(int?)
                || t == typeof(long) || t == typeof(long?)
                || t == typeof(DateTime) || t == typeof(DateTime?) || t == typeof(char) || t == typeof(decimal) || t == typeof(decimal?))
                p.SetValue(objDest, p.GetValue(objSource, null), null);
        }
    }