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顯示產生的四位隨機數;
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顯示產生的四位隨機數;
}
}
}