随机赋值
有什么简单的方法给一个变量随机赋值吗?
1.产生随机整数
Random ra = new Random();
int num = ra.Next(1,100);
This.Label1.Text = num.ToString();
2.产生随机正负数
Random ra = new Random();
int num = ra.Next(-100,100);
This.Label1.Text = num.ToString();
3.产生随机小数
Random ra = new Random();
Double num = ra.NextDouble();
This.Label1.Text = num.ToString();