C# Array.FindAll

 1  string[] arrySource = { "C#111", "C#22222", "C222", "safdaf", "Cwedad" };
 2  string[] tempResult;
 3  private void Form1_Load(object sender, EventArgs e)
 4  {
 5             
 6     DisplayView(arrySource, txtSource);
 7  }
 8  public void DisplayView(string [] sourece,TextBox txtView)
 9   {
10     txtView.Enabled = false;
11     for (int i = 0; i < sourece.Length; i++)
12        {
13          txtView.Text += sourece[i] + "\r\n";
14        }
15   }
16
17  private void txtSerach_TextChanged(object sender, EventArgs e)
18  {
19    tempResult=Array.FindAll<string>(arrySource, (s) => s.Contains(txtSerach.Text));
20    //tempResult= Array.FindAll(arrySource, (s) => s.Contains(txtSerach.Text));
21     txtResult.Clear();
22     DisplayView(tempResult, txtResult);
23  }

 

 

posted @ 2015-11-06 10:49  NSkG  阅读(1453)  评论(0编辑  收藏  举报