C# Error CS8141 – The tuple element names in the signature of method ‘{0}’ must match the tuple element names of interface method ‘{1}’ (including on the return type).

C# Error

CS8141 – The tuple element names in the signature of method ‘{0}’ must match the tuple element names of interface method ‘{1}’ (including on the return type).

Reason for the Error & Solution

The tuple element names in the signature of method must match the tuple element names of interface method (including on the return type).

Example

The following sample generates CS8141:

// CS8141.cs (10,27)
using System.Collections;

public interface IGrabber<out T>
{
    T GetOne();
}

class SomeGrabber : IGrabber<(int, int)>
{
    public (int a, int b) GetOne()
    {
        return (1, 2);
    }
}

To correct this error

Changing the signature of the GetOne method to return an unnamed tuple, matching the unnamed tuple in the interface, will correct this error:

    public (int, int) GetOne()
    {
        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...