.net 关于匿名类型的特性
匿名类型
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));
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。