C军

不玩博客了!

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

一、一个字符串,一个字符串数组。判断字符串数组里的元素出现在字符串中的有几个。

    class Program
    {
        static void Main(string[] args)
        {
            string str = "你在他乡还好吗?";
            string[] WordList = new string[] {"他乡","家庭","还好","怎么" };
            int count = WordList.Where(m => str.Contains(m)).Count();

            Console.WriteLine(count);   //输出2

            Console.ReadKey();
        }
    }

 

posted on 2013-06-13 11:14  逆心  阅读(537)  评论(0编辑  收藏  举报