foreach套在for中为什么不走了呢
{
Response.Write("show()方法");
int right_code = 0;
List<int> list = ShowMenu();
string rightSql = "select * from sys_right where right_code = "+right_code;
List<Right> rightList = new List<Right>();
DataTable rightTable = null;
for (int i = 0; i < list.Count; i++)
{
Response.Write("for循环");
right_code = list[i];
rightTable = DbHelp.ReturnDataTable( rightSql);
Response.Write("list中的值"+list[i]);
if (i<list.Count)
{
Response.Write("进入if循环了+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
foreach (DataRow rightrow in rightTable.Rows)
{
Response.Write("进入foreach循环了+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
Right rr = new Right();
rr.Right_code = Convert.ToInt32(rightrow["right_code"]);
rr.Right_parent_code = Convert.ToInt32(rightrow["right_parent_code"]);
rr.Right_text = Convert.ToString(rightrow["right_text"]);
rr.Right_url = Convert.ToString(rightrow["right_url"]);
rr.Right_type = Convert.ToString(rightrow["right_type"]);
string node = "";
string head = "";
if (rr.Right_type == "Folder")
{
head = "<h1 class=\"type\"><a href=\"javascript:void(0)\" target=\"mainFrame\">\"" + rr.Right_text + "\"</a></h1>";
}
string center = "<div class=\"content\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr><td><img src=\"images/menu_topline.gif\" width=\"160\" height=\"5\" alt=\"\" /></td></tr></table>";
string foot = " <ul class=\"MM\"><li><a href=\"" + rr.Right_url + "\" target=\"mainFrame\">\"" + rr.Right_text + "\"</a></li></ul>";
node = head + center + foot;
mainMenu.InnerHtml += node;
Response.Write(node);
rightList.Add(rr);
}
}
else
{
break;
}
}
}
相关推荐
老生常谈foreach(增强for循环)和for的区别
下面小编就为大家带来一篇老生常谈foreach(增强for循环)和for的区别。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
有了 for 循环 为什么还要 forEach ?
本质区别for循环和forEach的语法区别for循环和forEach的性能区别js中那么多循环,forfor...infor...offorEach,有些循环感觉上是大同小异今天我们讨论下for循环和forEach的差异。for循环和forEach的本质区别。for循环和forEach的语法区别。for循环和forEach的性能区别。
详解Java中的增强 for 循环 foreach
foreach 是 Java 中的一种语法糖,几乎每一种语言都有一些这样的语法糖来方便程序员进行开发,编译期间以特定的字节码或特定的方式来对这些语法进行处理。能够提高性能,并减少代码出错的几率。
C#中foreach循环对比for循环的优势和劣势
前言 循环语句为众多程序员们提供了很大的便利,有while、do…while、for和 foreach。而且foreach语句很简洁,但是它的优点不仅仅在于此,它的效率也是最高的。本文将详细给大家关于C#中foreach循环对比for循环的优势和劣势,下面话不多说了,来一起看看详细的介绍吧。 一、foreach循环的优势 C#支持foreach关键字,foreach在处理集合和数组相对于for存在以下几个优势: 1、foreach语句简洁 2、效率比for要高(C#是强类型检查,for循环对于数组访问的时候,要对索引的有效值进行检查) 3、不用关心数组的起始索引是几(因为有很多开发者是从其他语
for,foreach,iterator的用法和区别
for,foreach,iterator的用法和区别


