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 First
{
public partial class Form1 : Form
{
string[] names = System.IO.File.ReadAllLines("names.txt");
Random r = new Random();
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
this.button1.Visible = true;
}
private void button1_Click(object sender, EventArgs e)
{
//string[] names=System.IO.File.ReadAllLines("names.txt");
//Random r = new Random();
//int a = r.Next(names.Length);
//this.label1.Text = "中奖的同学是:"+names[a];
if (this.timer1.Enabled)
{
this.timer1.Enabled = false;
}
else
{
this.timer1.Enabled = true;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
int a = r.Next(names.Length);
this.label1.Text = "中奖的同学是:" + names[a];
}
}
}
相关分类