委托的匿名方法
阿新 • • 發佈:2018-11-10
ret nbsp code 委托 def dal void clas string
1 class Program 2 { 3 static void Main(string[] args) 4 { 5 List<string> list = new List<string>() { "abf", "cde", "def" }; 6 List<string> resultList = list.FindAll( 7 delegate(string s) 8 {9 return s.IndexOf(‘f‘) >= 0; 10 } 11 ); 12 string[] resulStrings = resultList.ToArray(); 13 foreach (var s in resulStrings) 14 { 15 Console.WriteLine(s); 16 } 17 18 } 1920 }
委托的匿名方法