编译器错误 CS0745
应为上下文关键字 "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;
}
}