select与selectMany区别

            string[] text = { "Albert was here", "Burke slept late", "Connor is happy" };
            var tokens = text.Select(s => s.Split(' '));
            foreach (string[] line in tokens)
                foreach (string token in line)
                    Console.Write("{0}.", token);

            var tokens1 = text.SelectMany(s => s.Split(' '));
            foreach (string token in tokens1)
                Console.Write("{0}.", token);

            Console.ReadKey();

执行结果一样
输出:Albert.was.here.Burke.slept.late.Connor.is.happy.

你可能感兴趣的:(后端)