using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 随机数
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Random rad = new Random();//实例化随机数产生器rad;
int value = rad.Next(1000, 10000);//用rad生成大于等于1000,小于等于9999的随机数;
label1.Text = value.ToString(); //用label控件label1显示产生的四位随机数;
}
}
}
Random r = new Random();
label1.Text = r.Next(1000, 10000).ToString();
利用random函数就可以啊
怎样才能生成完全的随机数啊!!~