Interface variant return type

I have two classes for example. Each of them have a Deconstruct() method. How can I represent this in an interface?

public class A
{
    public Foo Foo { get; }
    pubiic Bar Bar { get; }
    public Baz Baz { get; }

    public (Foo, Bar, Baz) Deconstruct()
    {
        return (Foo, Bar, Baz); 
    }
}

public class B 
{
    public Foo Foo { get; }
    pubiic Bar Bar { get; }

    public (Foo, Bar) Deconstruct()
    {
        return (Foo, Bar);
    }
}

public interface IDeconstructable
{
    (variable return type) Deconstruct(); 
}


Read more here: https://stackoverflow.com/questions/65700404/interface-variant-return-type

Content Attribution

This content was originally published by Matthew Trip at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: