編譯器錯誤 CS0745
必須是內容關鍵字 'by'
group
子句的模式是後面接著選擇性 group...by
的 into
(如下列範例所示):
C#
string[] names = { "Bob", "Bill", "Jonetta", "Mary" };
var query = from name in names
group name by name[0];
或
C#
var query2 = from name in names
group name by name[0] into g
//...additional query clauses
- 請將
by
關鍵字加入group
子句。
下列程式碼會產生 CS0745:
C#
// 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;
}
}