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

推荐订阅源

小众软件
小众软件
B
Blog RSS Feed
美团技术团队
博客园 - 【当耐特】
C
Check Point Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
Vercel News
Vercel News
P
Proofpoint News Feed
IT之家
IT之家
I
InfoQ
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - 踏踏实实干

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);
        }
    }