.net程序随机抽取试卷改成按顺序抽取!
请教大家,我有个随机的问题,我刚在学.net程序,有下到一个源码,就是随机抽取考卷的,下面是随机的,但是我想把随机改成不随机的,按输入考题的顺序排列,该怎么样呢?谁能解答下:
下面是部分代码,请问要改哪些?
tx_extime.Value = Kminfo[3];
string lst = roandow_data(mySet.Tables[0].Rows.Count, int.Parse(Kminfo[1]));
txID.Text = lst;
txVuale.Text = Kminfo[2];
string[] lsts=lst.Split(';');
for (int i=0;i<lsts.Length;i++)
{
Table ntb = new Table();
TD1.Controls.Add(ntb);
TableRow ntr = new TableRow();
ntb.Controls.Add(ntr);
TableCell ntc = new TableCell();
ntr.Controls.Add(ntc);
Label nlb = new Label();
nlb.Font.Bold = true;
nlb.Font.Size = 11;
nlb.Text = (i+1).ToString() + "、" + mySet.Tables[0].Rows[int.Parse(lsts[i])]["q_question"].ToString();
ntc.Controls.Add(nlb);
ntr = new TableRow();
ntb.Controls.Add(ntr);
ntc = new TableCell();
ntr.Controls.Add(ntc);
RadioButtonList nrbl = new RadioButtonList();
for (char ia = 'A'; ia <= 'D'; ia++)
{
ListItem li = new ListItem();
li.Text = ia.ToString() + "、" + mySet.Tables[0].Rows[int.Parse(lsts[i])]["q_key" + ia.ToString()].ToString();
li.Value = ia.ToString();
nrbl.Items.Add(li);
}
nrbl.ID = "q_" + mySet.Tables[0].Rows[int.Parse(lsts[i])]["q_id"].ToString();
ntc.Controls.Add(nrbl);
}
Button1.Visible = true;
}
private string roandow_data(int allcount, int thecount)
{
Random rnd = new Random();
List<int> lst = new List<int>();
int i = 0;
string str = "";
while (i < thecount)
{
int j = rnd.Next(allcount);
if (lst.IndexOf(j) == -1)
{
lst.Add(j);
i++;
}
}
foreach (int j in lst)
{
if (str.Length == 0)
{
str = j.ToString();
}
else
{
str = str + ";" + j.ToString();
}
}
return str;
哪位能够解答下!!