产生一个int数组,长度为10,并向其中随机插入1-10,并且不能重复
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
//产生一个int数组,长度为10,并向其中随机插入1-10,并且不能重复
int[] myArr= new int[10];
ArrayList myList = new ArrayList();
Random rnd = new Random();
while (myList.Count < 10)
{
int num = rnd.Next(1, 10 + 1);
if (!myList.Contains(num))
{
myList.Add(num);
}
}
for (int i = 0; i < 10; i++)
{
myArr[i] = (int)myList[i];
Response.Write("第" + i + "个数为:" + myArr[i] + "<br>");
}