C# 匿名类与匿名对象的用法

string json = new { mobile = phoneNum }.ToJson();
// var news = new { title = "特大喜讯", author = "夕阳眼", postdate = "3013-10-9", msg = "今晚公布" };

读取匿名类对象的属性值,有如下线程传入对象

t.Start(new { dcid =entity.dcid, name=entity.name,nodeText=e.Node.Text });

读取线程传入匿名对象值的方法。

string dcid = obj.GetType().GetProperty("dcid").GetValue(obj);
string name = obj.GetType().GetProperty("name").GetValue(obj);
string nodeText = obj.GetType().GetProperty("nodeText").GetValue(obj);


https://www.cnblogs.com/dandandeyoushangnan/p/4523710.html

原文地址:https://www.cnblogs.com/lihuali/p/8038645.html