匿名类型
1: var n1 = new { name = "name1", age = 40 }; 2: var n2 = new { name = "name2", age = 31 }; 3: var n3 = new { name = "name3", age = 32 }; 4: Console.WriteLine("{0} is {1} years old",n1.name,n1.age);
结合数组应用
var family = new[] { new { name = "Holly", age = 31 }, new { name = "Jon", age = 31 } };
结合序列化
var list = new List<object>(); for (int i = 0; i < id_arrt.Length; i++) { list.Add(new { Name = "Tom", Age = 4 }); } context.Response.Write(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(list));
时间: 2024-10-12 09:25:33