摘要:抽籤完成版
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Ballot
{
public partial class Ballot : System.Web.UI.Page
{
int[] num = new int[10];
Random rand = new Random();
protected void Button1_Click(object sender, EventArgs e)
{
for (int u = 0; u < 10; u++)
{
Label1.Text += choose(num);
}
}
public string choose(int [] arr)
{
int temp, j = 0;
string str = "";
while (j < 10)
{
temp = rand.Next(1, 100);
if (!arr.Any(m => m.Equals(temp)))
{
arr[j] = temp;
j++;
}
}
Array.Sort(arr);
for (int u = 0; u < 10; u++)
{
str += arr[u].ToString() + ",";
}
return str + "</br>";
}
}
}