C#中怎么生成4位随机数???
各位大大...各种求助啊...郁闷了好就都没弄好...... 展开
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显示产生的四位随机数;
}
}
}
label1.Text = r.Next(1000, 10000).ToString();