C#匿名对象序列化

//匿名对象序列化
var obj=new { Name = "张三", Age = 15 };
Console.WriteLine(JsonConvert.SerializeObject(obj));

//匿名集合序列化
List<object> list = new List<object>();
list.Add(new { Name = "张三", Age = 15 });
list.Add(new { Name = "张三2", Age = new {Add="重庆",Birth="2016-09-01" } });

Console.WriteLine(JsonConvert.SerializeObject(list));

 

posted @ 2016-10-28 20:32  段江涛IT  阅读(2016)  评论(0编辑  收藏  举报
页脚HTML代码