lamda表达式不太熟,怎样获取一个字符串数组names中以"00"结束的字符串数组

解决方案 »

  1.   

      //数组
                String[] m = {"00", " 1", " 2", "3", " 4", " 5", " 6", "7",
      " 8","9","10","11","12","13","14","100","200","1700","18","19","20","21","22","23"};
                m.ToList<string>().ForEach(
                item =>
                {
                    MatchCollection matchs = Regex.Matches(item, ".*00$", RegexOptions.Singleline);
                    foreach (Match match in matchs)
                    {
                        Console.WriteLine(match.Groups[0].Value);
                    }
                }
                   );
                Console.ReadKey();
      

  2.   


    var query=names.Where(n=>n.EndWith("00")).ToArray();