Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a bug in this code from 101 LINQ Samples on MSDN? (Update: Fixed)
    primarykey
    data
    text
    <p><strong><em>NOTE: <a href="https://stackoverflow.com/users/253576/ccalvert">Charlie Calvert</a> replied below that the 101 LINQ Samples have now been updated with correct code.</em></strong></p> <p>The MSDN Visual C# Developer Center has a section called <strong>101 LINQ Samples</strong>. I found this through a Bing search.</p> <p>The code for <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336758#SelectManyCompoundfrom1" rel="nofollow noreferrer">SelectMany - Compound from 1</a> is:</p> <pre><code>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 &lt; b select new {a, b}; Console.WriteLine("Pairs where a &lt; b:"); foreach (var pair in pairs) { Console.WriteLine("{0} is less than {1}", pair.a, pair.b); } } </code></pre> <p>However, <strong>this code won't compile</strong>. I noticed that if I remove the comma at the end of <code>from a in numbersA,</code> and instead add <code>from</code> in front of <code>b in numbersB</code>, it will compile and work fine:</p> <pre><code> var pairs = from a in numbersA from b in numbersB where a &lt; b select new {a, b}; </code></pre> <p>I'm not sure if this is a bug in MSDN's example or if possibly I'm running a version of C# and .NET that doesn't support this syntax.</p> <p>If I look at the breadcrumb at the top of the <strong>101 LINQ Samples</strong> website, I see it says "Future Versions". Does this indicate that future versions of C#/.NET will support using a comma instead of <code>from</code> in LINQ syntax?</p> <p><img src="https://i474.photobucket.com/albums/rr103/ossavir/LINQ_sample_breadcrumb.png"></p> <p>I'm using Visual Studio 2008 Standard with .NET 3.5 SP1.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload