question

Sergio-9977 avatar image
0 Votes"
Sergio-9977 asked Sergio-9977 answered

LINQ causes errors

LINQ gives me errors and I use examples from the microsoft site

Link: https://docs.microsoft.com/it-it/dotnet/csharp/linq/write-linq-queries
Example
using System;
using System.Collections;

namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
// Query #1.
List<int> numbers = new List<int>() { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };

         // The query variable can also be implicitly typed by using var
         IEnumerable<int> filteringQuery =
             from num in numbers
             where num < 3 || num > 7
             select num;

         // Query #2.
         IEnumerable<int> orderingQuery =
             from num in numbers
             where num < 3 || num > 7
             orderby num ascending
             select num;

         // Query #3.
         string[] groupingQuery = { "carrots", "cabbage", "broccoli", "beans", "barley" };
         IEnumerable<IGrouping<char, string>> queryFoodGroups =
             from item in groupingQuery
             group item by item[0];
     }
 }

}

Thanks

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Sergio-9977 avatar image
0 Votes"
Sergio-9977 answered

Sorry, but I found the error were caused by the missing reference to
using System.Linq;
using System.Collections.Generic;

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.