HomeCSharpC# 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}’.

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

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...