C# Error CS8140 – ‘{0}’ is already listed in the interface list on type ‘{2}’ with different tuple element names, as ‘{1}’.

C# Error

CS8140 – ‘{0}’ is already listed in the interface list on type ‘{2}’ with different tuple element names, as ‘{1}’.

Reason for the Error & Solution

is already listed in the interface list on type with different tuple element names, as.

Example

The following sample generates CS8140:

// CS8140.cs (11,7)

interface I<T>
{
    T GetValue();
}

interface I2 : I<(int c, int d)>
{
}

class C : I<(int a, int b)>, I2
{
    public (int c, int d) GetValue()
    {
        return (1, 2);
    }
}

To correct this error

Renaming the tuple element names to match the interface declaration corrects this error:

interface I<T>
{
    T GetValue();
}

interface I2 : I<(int c, int d)>
{
}

class C : I<(int c, int d)>, I2
{
    public (int c, int d) GetValue()
    {
        return (1, 2);
    }
}

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...