Does this code describe an Existential Type in C#?

Posted by noblethrasher on Stack Overflow See other posts from Stack Overflow or by noblethrasher
Published on 2010-05-19T03:59:17Z Indexed on 2010/05/19 4:00 UTC
Read the original article Hit count: 243

Filed under:
|

Currently watching Bart De Smet's explanation of IQueryable and he mentioned Existential Types (which I've been curious about for some time). After reading the answers to this question I'm just wondering if this is a way to construct it in C#:

public abstract class ExistentialType
{
    private ExistentialType() { }


    public abstract int Foo();

    public ExistentialType Create()
    {
        return new ConcreateType1();
    }

    private class ConcreateType1 : ExistentialType
    {
        public override int Foo()
        {
            throw new NotImplementedException();
        }
    }

    private class ConcreateType2 : ExistentialType
    {
        public override int Foo()
        {
            throw new NotImplementedException();
        }
    }

    private class ConcreateType3 : ExistentialType
    {
        public override int Foo()
        {
            throw new NotImplementedException();
        }
    }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about existential-type