日期:2014-05-18  浏览次数:20872 次

c# 泛型和委托

List<T> lst=new List<T>();
List<T> l=lst.FindAll(delegate(T t){return t.name.Contains("a");});
或使用LINQ

 

 

       private void button1_Click(object sender, EventArgs e)
        {
            List
<string> myList = new List<string>();
           
for(int i = 0; i < 10; i++)
            {
                myList.Add(i.ToString ());
//我给他填充1--10
            }

           
if (myList.Find(MathChar) != null)
            {
                MessageBox.Show(
"有这个元素");
            }
           
else
            {
                MessageBox.Show(
"没有这个元素");
            }
        }


       
private bool MathChar(string str)
        {

           
if (str.Equals(&qu