Share via


Compiler Error CS1940

Multiple implementations of the query pattern were found for source type 'type'. Ambiguous call to 'method'.

This error is generated when multiple implementations of a query method are defined and the compiler cannot disambiguate which one is best to use for the query. In the following example, both versions of Select have the same signature, because they both accept one int as an input parameter and have int as a return value.

To correct this error

  • Provide only one implementation for each method.

Example

The following code generates CS1940:

// cs1940.cs
using System; //must include explicitly for types defined in 3.5
class Test
{
    public delegate int Dele(int x);
    int num = 0;
    public int Select(Func<int, int> d)
    {
        return d(this.num);
    }
    public int Select(Dele d) // CS1940
    {
        return d(this.num) + 1;
    }
    public static void Main()
    {
        var q = from x in new Test()
        select x;
    }
}

See Also

Concepts

Standard Query Operators Overview