C#动态创建对象和其属性
阅读原文时间:2023年07月12日阅读:1

       dynamic contact = new ExpandoObject();
contact.Name = "Patrick Hines";
contact.Phone = "206-555-0144";
contact.Address = new ExpandoObject();
contact.Address.Street = "123 Main St";
contact.Address.City = "Mercer Island";
contact.Address.State = "WA";
contact.Address.Postal = "68402";
string res = JsonConvert.SerializeObject(contact);