R
Rich P
The following sample linq query wont compile - 1st error says "a query
body must end with a select clause or a group clause" and then says I
need ";"..., invalid "in". Do I need to add an additional using
statement? Or change the syntax below for a compound from?
------------------------------------------------
The sample uses a compound from clause to compose a query that returns a
sequence of the pairs.
public void Linq14() {
int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };
int[] numbersB = { 1, 3, 5, 7, 8 };
var pairs =
from a in numbersA,
b in numbersB
where a < b
select new {a, b};
Console.WriteLine("Pairs where a < b:");
foreach (var pair in pairs) {
Console.WriteLine("{0} is less than {1}", pair.a, pair.b);
}
}
------------------------------------------------
Thanks
Rich
body must end with a select clause or a group clause" and then says I
need ";"..., invalid "in". Do I need to add an additional using
statement? Or change the syntax below for a compound from?
------------------------------------------------
The sample uses a compound from clause to compose a query that returns a
sequence of the pairs.
public void Linq14() {
int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };
int[] numbersB = { 1, 3, 5, 7, 8 };
var pairs =
from a in numbersA,
b in numbersB
where a < b
select new {a, b};
Console.WriteLine("Pairs where a < b:");
foreach (var pair in pairs) {
Console.WriteLine("{0} is less than {1}", pair.a, pair.b);
}
}
------------------------------------------------
Thanks
Rich