编译器错误 CS0743
应为上下文关键字 "on"
join
子句的模式是 join
...in
...on
...equals
,如本示例所示:
var query = from x in array1
join y in array2 on x equals y
select x;
- 将
on
关键字添加到join
子句中。
下面的代码生成 CS0743:
// cs0743.cs
using System;
using System.Linq;
public class C
{
public static int Main()
{
int[] array1 = { 1, 2, 3, 4, 5, 6 };
int[] array2 = { 5, 6, 7, 8, 9 };
var c = from x in array1
join y in array2 x equals y // CS0743
select x;
return 1;
}
}