C# Error CS1935 – Could not find an implementation of the query pattern for source type ‘{0}’. ‘{1}’ not found. Are you missing required assembly references or a using directive for ‘System.Linq’?

C# Error

CS1935 – Could not find an implementation of the query pattern for source type ‘{0}’. ‘{1}’ not found. Are you missing required assembly references or a using directive for ‘System.Linq’?

Reason for the Error & Solution

Could not find an implementation of the query pattern for source type ‘type’. ‘method’ not found. Are you missing a using directive for ‘System.Linq’?

The source type in a query must be IEnumerable, IEnumerable<T>, or a derived type, or a type for which you or someone else has implemented the standard query operators. If the source type is an IEnumerable or IEnumerable<T>, you must add a using directive for the System.Linq namespace in order to bring the standard query operator extension methods into scope. Custom implementations of the standard query operators must be brought into scope in the same way, with a using directive and, if necessary, a reference to the assembly.

To correct this error

Add the required using directives and references to the project.

Example

The following code generates CS1935 because the using directive for System.Linq is commented out:

// cs1935.cs
// CS1935
using System;
using System.Collections.Generic;
// using System.Linq;

class Test
{
    static int Main()
    {
        int[] nums = { 0,1,2,3,4,5 };
        IEnumerable<int> e = from n in nums
                        where n > 3
                        select n;
        return 0;
    }
}

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...