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 WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } List data = new List(); List data0 = new List(); List data1 = new List(); List data2 = new List(); Button b; private void Form1_Load(object sender, EventArgs e) { data.Clear(); data0.Clear(); data1.Clear(); data2.Clear(); for (int i = 0; i < 30000; i++) { MyData d = new MyData(); d.hogehoe = i; data.Add(d); if (i < 10000) { data0.Add(d); } else if (i < 20000) { data1.Add(d); } else { data2.Add(d); } } b = new Button(); b.Text = "実行"; b.Click += new EventHandler(b_Click); this.Controls.Add(b); } void b_Click(object sender, EventArgs e) { b.Enabled = false; int i = 29999; MyData aheahe; if (i < 10000) { aheahe = this.datafind(data0, i); } else if (i < 20000) { aheahe = this.datafind(data1, i); } else { aheahe = this.datafind(data2, i); } if (aheahe != null) this.Text = aheahe.hogehoe.ToString(); b.Enabled = true; } MyData datafind(List kkkkkkkk, int number) { MyData mmmm = null; foreach (MyData md in kkkkkkkk) { if (md.hogehoe == number) { mmmm = md; break; } } return mmmm; } } public class MyData { public int hogehoe; } }