public class RandomRange
{
private int range = 0;
private object[] container;
private Random rand;
public RandomRange(object[] container)
{
this.container = container;
this.range = container.Length;
long time = DateTime.Now.Ticks;
string temp = Convert.ToString(time,2).PadLeft(64,'0');
string temp2 = temp.Substring(32,32);
int i = Convert.ToInt32(temp2,2);
rand = new Random(Convert.ToInt32(temp2,2));
}
public void DoRange()
{
int j = 0;
for(int i=0;i<range;i++)
{
j = rand.Next(range);
Switch(i,j);
}
}
int i,j;
for(j=0 ;j<10000;j++) //让它在里面搅1000次
{
Random rnd1 =new Random(10);//这个10按你数组的大小来定
Random rnd2 = new Random(10);
int a ,b,temp;
a=(int)rnd1;
b=(int)rnd2;
temp=intD[rnd1];
intD[rnd1]=intD[rnd2];
intD[rnd2]=temp;
}