language: C# (mono-2.8)
date: 97 days 4 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
//using System.Data.Linq;
//using System.Xml;
//using System.Xml.Linq;
 
namespace linqsamples
{
        /// <summary>
        /// Summary description for LinqSample
        /// </summary>
        class LinqSample
        {
           public static void Main()
           {
                int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; 
                var numGroups = from n in numbers group n by n % 5 into g
                        select new {Remainder = g.Key, Numbers = g};
                        
                foreach(var g in numGroups)
                {       
                        
                        Console.WriteLine("Number with remainder {0} when devided by 5:",g.Remainder);
                        
                        foreach(var n in g.Numbers )
                        {
                                Console.WriteLine(n);
                        }
                }                       
 
           }
                
        }
}
 
prog.cs(16,51): error CS1935: An implementation of `GroupBy' query expression pattern could not be found. Are you missing `System.Linq' using directive or `System.Core.dll' assembly reference?
prog.cs(19,17): error CS1579: foreach statement cannot operate on variables of type `object' because it does not contain a definition for `GetEnumerator' or is inaccessible
Compilation failed: 2 error(s), 0 warnings