当前位置:网站首页>C#将对象转换为Dictionary字典集合
C#将对象转换为Dictionary字典集合
2022-08-04 19:44:00 【幕尘枫】
/// <summary>
/// 将对象转换为字典集合
/// </summary>
/// <param name="zone">对象</param>
/// <returns></returns>
public Dictionary<string, string> ObjectToMap(Zone zone)
{
Dictionary<string, string> map = new Dictionary<string, string>();
PropertyInfo[] list = zone.GetType().GetProperties();
foreach (PropertyInfo p in list)
{
//Console.WriteLine("键:" + p.Name + ",值:" + p.GetValue(zone, null));
map.Add(p.Name, p.GetValue(zone, null).ToString());
}
return map;
}边栏推荐
猜你喜欢
随机推荐
「 WAIC 2022 · 黑客马拉松」蚂蚁财富两大赛题邀你来战!
使用.NET简单实现一个Redis的高性能克隆版(二)
QT 小知识随记
"WAIC 2022 · hackers marathon" two ants wealth competition invited you to fight!
JS new一个构造器发生了什么?从零手写一个new方法
June To -.-- -..- -
nr part calculation
seata源码解析:seata server各种消息处理流程
Spark提交参数说明和常见优化
The list of Kubernetes - watch mechanism
SAP UI5 确保控件 id 全局唯一的实现方法
基于HDF的LED驱动程序开发(2)
如何让远在的老板看到你!----------来自财富中国网
QCustomPlot 坐标轴间隔显示刻度标签
Switch node version and switch npm source tool
Storage resource activation system to help new infrastructure
Video Object Detection
MMDetection usage example: from entry to exit
重构指标之如何监控代码圈复杂度
To -.-- -..- -









