将数据字典转换为对象 [英] convert data dictionary to object

查看:367
本文介绍了将数据字典转换为对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

有没有办法制作一个带有对象名称并将数据字典类型转换为此对象类型的函数



只需将对象名称传递给ex:



  public  objectType函数(objectType,List< Dictionary< string,string>> _lstDic)
{
foreach > var kvpList in _lstDic)
JsonConvert.DeserializeObject< objectType(JsonConvert.SerializeObject(kvpList));
}



where objectType(person or Customer,....)

  public   class 客户
{
// 字段,属性,方法和事件都在这里......
}

解决方案

请检查以下解决方案。



http://stackoverflow.com/questions/4943817/mapping-object-to-dictionary -and-反之亦然

dear all,
Is there any way to make a function that take the name of object and convert the data dictionary type to this object type

just by passing the name of object for ex:

 public objectType function (the objectType,List<Dictionary<string, string>> _lstDic)
{
foreach (var kvpList in _lstDic)
JsonConvert.DeserializeObject<"objectType"(JsonConvert.SerializeObject(kvpList));
}


where objectType (person or Customer,....)

public class Customer
{
    //Fields, properties, methods and events go here...
}

解决方案

Please check the below solution.

http://stackoverflow.com/questions/4943817/mapping-object-to-dictionary-and-vice-versa


这篇关于将数据字典转换为对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆