using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Configuration;
using System.Data.SqlClient;
using System.IO;
namespace Monitoring
{
public partial class Monitoring : Form
{
public Monitoring()
{
InitializeComponent();
}
string arry = "";
private void Monitoring_Load(object sender, EventArgs e)
{
}
/// <summary>
/// 获取随机数的方法 返回一个值
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void NumLoad()
{
int a = Convert.ToInt32(textBox1.Text);
ArrayList myList = new ArrayList();
Random rnd = new Random();
int num = rnd.Next(1, 11);
if (num ==Convert.ToInt32( textBox2.Text))
{
NumLoad();
}
bool dd = checkNum(num.ToString());
if (dd)
{
arry += "," + num;
}
else
{
NumLoad();
}
}
//判断历史随机数的方法 返回bool值
public bool checkNum(string x)
{
string[] i = arry.Split(',');
bool z = false;
if (i.Length > 0)
{
for (int j = 0; j < i.Length; j++)
{
if (x != i[j])
{
z = true;
continue;
}
else
{
z = false;
break;
}
}
}
return z;
}
//如果bool值为真则累加arry以“,”分隔
private void button1_Click(object sender, EventArgs e)
{
NumLoad();
label1.Text = arry;
}
}
}