更新:2007 年 11 月
错误消息
需要上下文关键字“by”group 子句的格式为 group...by 后跟一个可选的 into,如下面的示例所示:
复制代码 | |
---|---|
string[] names = { "Bob", "Bill", "Jonetta", "Mary" }; var query = from name in names group name by name[0]; |
或者
复制代码 | |
---|---|
var query2 = from name in names group name by name[0] into g //...additional query clauses |
更正此错误
将 by 关键字添加到 group 子句中。
示例
下面的代码生成 CS0745:
复制代码 | |
---|---|
// cs0745.cs using System; using System.Linq; public class C { public static int Main() { string[] names = { "Bob", "Bill", "Jonetta", "Mary" }; var query = from name in names group name name[0]; // CS0745 return 1; } } |