Passing derived objects in a constructure

Posted by Clarence Klopfstein on Stack Overflow See other posts from Stack Overflow or by Clarence Klopfstein
Published on 2010-05-20T16:38:33Z Indexed on 2010/05/20 16:40 UTC
Read the original article Hit count: 149

Filed under:
|
|
|
|

This is a bit of a convoluted question, hopefully I can make it clear.

I am finding that this may not be possible, but am trying to see if anybody has a solution.

I have four classes, two are core classes and two are those core classes extended:

extUser Extends coreUser
extSecurity Extends coreSecurity

In the constructor for coreUser you have this:

public coreUser(string id, ref coreSecurity cs)

When trying to extend coreUser you would have this:

public extUser(string id ref extSecurity es) : base(id, ref es)

This fails because es is of type, extSecurity and the base class expects a type of coreSecurity. I've not found anyway to cast this to allow for me to override this base class in C#. In VB it works just fine.

Ideas?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#