有没有为Queryable.SelectMany()方法的C#语法LINQ? [英] Is there a C# LINQ syntax for the Queryable.SelectMany() method?

查看:369
本文介绍了有没有为Queryable.SelectMany()方法的C#语法LINQ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用C#语法LINQ编写一个查询,有没有使用Queryable.SelectMany方法从关键字语法的方法吗?

When writing a query using C# LINQ syntax, is there a way to use the Queryable.SelectMany method from the keyword syntax?

有关

string[] text = { "Albert was here", 
                  "Burke slept late", 
                  "Connor is happy" };



使用流利的方法我可以查询

Using fluent methods I could query

var tokens = text.SelectMany(s => s.Split(' '));

有一个查询语法类似于

var tokens = from x in text selectmany s.Split(' ')


推荐答案

是的,你只是重复的......在子句:

Yes, you just repeat the from ... in clause:

var words = from str in text
            from word in str.Split(' ')
            select word;

这篇关于有没有为Queryable.SelectMany()方法的C#语法LINQ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆