当前位置:编程学习 > C#/ASP.NET >>

asp.net语句注释

帮我注释一下每条语句的意思 越具体越好!!


public partial class _Default : System.Web.UI.Page
{
static ArrayList myList = new ArrayList();
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
int[] intS = new int[8];
string strT="";
int i;
bool blnExist=false ;

do
{
Random rd = new Random();
for (i = 0; i < 8; i++)
{
intS[i] = rd.Next(10);
strT = strT + intS[i].ToString();
}

for (i = 0; i < myList.Count; i++)
{
if (strT == myList[i].ToString())
{
blnExist = true;
break;
}
}
} while (blnExist);

myList.Add(strT);
this.ListBox1.Items.Add(strT);

if (myList.Count >= 10)
{
this.Button1.Enabled = false;
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Random rd = new Random();
int i;
string strT;

i = rd.Next(myList.Count);
strT = "三:" + myList[i];
myList.RemoveAt(i);
i = rd.Next(myList.Count);
strT=strT+"、" + myList[i];
myList.RemoveAt(i);
i = rd.Next(myList.Count);
strT = strT + "、" + myList[i]+"<br>";


i = rd.Next(myList.Count);
strT = strT+"二:" + myList[i];
myList.RemoveAt(i);
i = rd.Next(myList.Count);
strT = strT + "、" + myList[i]+"<br>";
myList.RemoveAt(i);

i = rd.Next(myList.Count);
strT = strT+"一:" + myList[i]+"<br>";

this.Label1.Text = strT;

this.Button1.Enabled = true;


}
}
答案:
public partial class _Default : System.Web.UI.Page 
{
static ArrayList myList = new ArrayList();//定义一个静态数组列表
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
int[] intS = new int[8];//定义一个整形数组并初始化
string strT="";
int i;
bool blnExist=false ;

do
{
Random rd = new Random();//定义一个随机函数
//循环取出8个随机函数并放到整形数组泌intS[i]中,再赋给字符串strT
for (i = 0; i < 8; i++)
{
intS[i] = rd.Next(10);
strT = strT + intS[i].ToString();
}

for (i = 0; i < myList.Count; i++)
{
if (strT == myList[i].ToString())//如果字符串与数组列表中的哪个相等
{
blnExist = true;
break;
}
}
} while (blnExist);//如果为true执行下面的语句

myList.Add(strT);//将字符串增加到数组列表
this.ListBox1.Items.Add(strT);//将字符串增加到ListBox1列表中

if (myList.Count >= 10)
{
this.Button1.Enabled = false;
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Random rd = new Random();//定义一个随机函数
int i;
string strT;

i = rd.Next(myList.Count);取出数组列表myList随机编号
strT = "三:" + myList[i];
myList.RemoveAt(i);//从数组列表中移除
//后面的都 一样啦
i = rd.Next(myList.Count);
strT=strT+"、" + myList[i];
myList.RemoveAt(i);
i = rd.Next(myList.Count);
strT = strT + "、" + myList[i]+"<br>";


i = rd.Next(myList.Count);
strT = strT+"二:" + myList[i];
myList.RemoveAt(i);
i = rd.Next(myList.Count);
strT = strT + "、" + myList[i]+"<br>";
myList.RemoveAt(i);

i = rd.Next(myList.Count);
strT = strT+"一:" + myList[i]+"<br>";

this.Label1.Text = strT;

this.Button1.Enabled = true;


}
}
直接说你哪不懂吧。一句一句的懒的全注释啊。
几个申明总知道吧?
第1个按钮事件,大概是初始化。 开始循环8次,把随机数+ 起来。放到个字符串中。
再把字符串丢到ArrayList 中去,当然。前面做了下判断。看他是否存在了。
连注释都让别人注。。。。

上一个:asp.net 高手关注!!!!!
下一个:怎样学好ASP.NET?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,