c# - Is there a bug in this code from 101 LINQ Samples on MSDN? (Update: Fixed) -


note: charlie calvert replied below 101 linq samples have been updated correct code.

the msdn visual c# developer center has section called 101 linq samples. found through bing search.

the code selectmany - compound 1 is:

public void linq14() {     int[] numbersa = { 0, 2, 4, 5, 6, 8, 9 };     int[] numbersb = { 1, 3, 5, 7, 8 };      var pairs =         in numbersa,              b in numbersb         < b         select new {a, b};      console.writeline("pairs < b:");     foreach (var pair in pairs) {         console.writeline("{0} less {1}", pair.a, pair.b);     } } 

however, this code won't compile. noticed if remove comma @ end of from in numbersa, , instead add from in front of b in numbersb, compile , work fine:

        var pairs =             in numbersa             b in numbersb             < b             select new {a, b}; 

i'm not sure if bug in msdn's example or if possibly i'm running version of c# , .net doesn't support syntax.

if @ breadcrumb @ top of 101 linq samples website, see says "future versions". indicate future versions of c#/.net support using comma instead of from in linq syntax?

i'm using visual studio 2008 standard .net 3.5 sp1.

yes, updated of 101 samples new code should less plagued these kinds of problems. posted lot of new code, , there still glitches, particularly around spacing, in better shape were. try accessing link now, , see if looks better:

http://msdn.microsoft.com/en-us/vcsharp/aa336758.aspx

  • charlie

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -