Tuesday, September 9, 2008

Getting into LINQ and error CS0742 (101 LINQ samples)

While checking what can be done with LINQ using the samples at:
http://msdn.microsoft.com/en-us/vcsharp/aa336758.aspx#SelectSimple1

I bumped into compile error:
error CS0742: A query body must end with a select clause or a group clause

Searching the web did not give good answer (only one saying this is not the correct syntax)

I had to go the VS help for select and From statemens titled: "from clause (C# Reference)"

  • The wrong syntax:
    from a in numbersA, b in numbersB
  • The correct syntax:
    from a in numbersA from b in numbersB
HTH

Dekel