关于C#List中FindAll用法的一些简单示例
(2012-03-29 11:36:23)
标签:
it |
分类: CSharp |
- using
System; - using
System.Collections.Generic; -
-
- public
partial classList : System.Web.UI.Page - {
-
void Page_Load( objectsender, EventArgs e) -
{ -
CreateList(); -
} -
-
void CreateList() -
{ -
List< list new= List< string>(); -
list.Add( -
list.Add( -
list.Add( -
list.Add( -
list.Add( -
list.Add( -
list.Add( -
list.Add( -
-
-
Response.Write( -
( stringstr inlist) -
{ -
Response.Write(str + -
} -
-
-
List< listFind delegate(string= list.FindAll( s){ -
s.Contains( "saurus"); -
}); -
-
Response.Write( -
( stringstr inlistFind) -
{ -
Response.Write(str+ ;" ); -
} -
-
-
Response.Write( -
List< subList //传入了一个方法名= list.FindAll(EndWithSaurus); -
( stringstr insubList) -
{ -
Response.Write(str+ ;" ); -
} -
-
} -
-
bool EndWithSaurus( strings) -
{ -
((s.Length "saurus"))> 5) && (s.Substring(s.Length - 6).ToLower() == -
true; -
-
false; -
} - }
过滤条件用法
List<string>
就可以了。其中itemType是你的元素的类型,即List <T>
中的类型参数T。