多类型匿名对象 var result = new { pages = , users = new System.Collections.ArrayList { ,name="}, ,name="} } }; result.users.Add(, name = " }); new { a = Tuple .Create( new List<Attribute>() { new MaskAttribute(".00") },), b = Tuple…
反序列化一个object var str1 = "{id:1,name:'111',x:[1,2,3],y:{a:'ssss',b:'dddd'}"; var obj1 = JsonConvert.DeserializeAnonymousType(str1, new {id=1,name="1",x=new[]{1,2},y=new{a="1",b="b"}}); 反序列化一个数组 var str2 = "[{id:…
一.关于匿名类型的特性 1.匿名类型 定义:匿名对象 var vobj = new { id = "编号", title = "标题", content = "内容" }; 访问: var id = vobj.id; 结果:编号 2.结合匿名数组应用 定义:集合初始化器 var article = new[] { new { id = "编号一", title = "标题一", content = &quo…
引用: using System.Web.Script.Serialization; 代码: var resp = new { flag = false, url = ConfigReader.LogoutPage }; JavaScriptSerializer serializer = new JavaScriptSerializer(); context.Response.Write(serializer.Serialize(resp)); 总结: JavaScriptSerializer…