1.返回IEnumerable类型
protected void Page_Load(object sender, EventArgs e)
{
IEnumerable ie = AllGet();
Response.Write(new JavaScriptSerializer().Serialize(ie));
}
public IEnumerable AllGet()
{
return new string[] { "Item1", "Item2" }.Select(s => new
{
Name = s,
Code = s,
Items = new ArrayList
{
new { Name = "Item1" },
new { Name = "Item2" },
new { Name = "Item3" },
new { Name = "Item4" },
}
});
}
结果:
[{"Name":"Item1","Code":"Item1","Items":[{"Name":"Item1"},{"Name":"Item2"},{"Name":"Item3"},{"Name":"Item4"}]},
{"Name":"Item2","Code":"Item2","Items":[{"Name":"Item1"},{"Name":"Item2"},{"Name":"Item3"},{"Name":"Item4"}]}] 2.返回List字符串类型
/// <summary>
/// ["1","a","0.5"]
/// </summary>
/// <returns>返回List字符串类型</returns>
public List<string> TestAjaxMethod(int a, string b, double c)
{
return new List<string> { a.ToString(), b, c.ToString() };
} 3.Dictionary应用
private Dictionary<int, string> dic = new Dictionary<int, string>(); 4.NameValueCollection集合
引用:using System.Collections.Specialized;
键是否重复,允许重复
NameValueCollection col = new NameValueCollection();
col.Add("red", "rojo");//如果键值red相同结果合并 rojo,rouge //显示键,值
PrintKeysAndValues(col); //按索引或值获取
col[1];//索引1的值
col["red"]);//键为red的对应值rojo //查找red键值然后删除
col.Remove("red"); for (int i = 0; i < col.Count; i++)
//清空集合
col.Clear(); //显示索引, 键,值
col.GetKey(i)
col.Get(i) foreach (string key in col.Keys)
col[key] 5.Hashtable集合
Hashtable与NameValueCollection相似;
HashTable是键-值集合,但键不能出现重复. Hashtable ht = new Hashtable();
ht.Add("key","value");

最新文章

  1. linux基础知识与技能2
  2. tyvj1294 小v的舞会
  3. webkitTransitionEnd webkitAnimationEnd事件
  4. The Number Off of FFF
  5. sublime text下代码太长brackethighlighter不能正确显示闭合高亮的解决方法
  6. 替换APK中的jar包文件
  7. struct stat 作用
  8. Controller 中Action 返回值类型 及其 页面跳转的用法
  9. 折腾源WRT的AC路无线路由-2
  10. flag.xls
  11. SEO学习知识
  12. PHP随机生成要求位数个字符(大小写字母+数字)
  13. protobuf 测试使用
  14. SSH框架下的表单重复提交
  15. samba基本应用24-4及示例
  16. jquery serialize对json的包装用法
  17. spring4-2-bean配置-1-依赖注入
  18. Centos中mount命令挂载windows7共享文件夹
  19. ORACLE 查看表空间
  20. 【UVA10561】Treblecross(SG函数)

热门文章

  1. ASIHTTPRequest-断点续传需要原网站支持!
  2. WordPress主题开发实例:查询单篇文章
  3. Git:基础要点
  4. VS2010Web默认的浏览器设置和VS里调试JavaScript代码的设置
  5. TortoiseSVN 和 VisualSVN
  6. DatabaseMirroring搭建
  7. [置顶] 不刷机让越狱后的iphone恢复出厂设置
  8. json schema校验
  9. C++ 反射机制的简单实现
  10. Mediator 中介者 MD