tags:

views:

135

answers:

1

I must be doing something wrong

public interface IActor
{
    //actor stuff
}

public class BaseShip : IActor
{
    //base ship stuff
}

public class PlayerShip: BaseShip
{
    //Only the stuff for this particular ship
}

Why then doesn't this work:

IActor player = new PlayerShip();

Or

List<IActor> actors = new List<IActor>(){new PlayerShip()};

I get Cannot convert from [PlayerShip] to [IActor]

note: snipped code for brevity


Update

I accidently defined the interface in two different namespaces. Nothing more to it.

+6  A: 

Are you certain this is your structure? I copied and pasted your code and the actions compiled and ran fine for me.

EDIT:

You guys need to step back for a second...interfaces certainly do propogate down the chain of inheritance. You're telling me that an inherited control doesn't implement IDisposable?

Adam Robinson
+1 It works for me as well.
Andrew Hare
His code worked for me, too.
Andy
Damn, It appears I defined the IActor at two different namespaces by accident. Will close the topic. Sorry
borisCallens
Mind accepting...?
Adam Robinson
Could you help closing?
borisCallens
@boris: No, only users with 3k or higher can vote to close.
Samuel