把多个不同的匿名对象加入到一个List中
一、创建一个控制台应用程序测试
static void Main(string[] args)
{
var data1 = new { Id = 1, Name = "ss" };
var data2 = new { Id = 2, Name = "yy", Age = 18 };
List<object> dateList = new List<object>() { data1, data2 };
Console.WriteLine(data1);
Console.WriteLine("------------");
Console.WriteLine(data2);
Console.WriteLine("------------");
Console.WriteLine(JArray.FromObject(dateList));
Console.ReadKey();
}
控制台输出: