0

A few days ago, I started "recoding" project from Java into C#. I encountered a few errors. The "biggest" one that I get the following error:

does not implement interface member

C# Code:

class Player : Entity
{
    //Main Class
    public void Kill(){ ... }
}

abstract class Entity : MapObject, Killable
{
    //...
}

abstract class MapObject
{
    //...
}

interface Killable
{
    void Kill();
}

In my Java project, the interface class is abstract, Entity class looks like:

abstract class Entity extends MapObject implements Killable {...}

And it works... So what is wrong with my C# code ?

Community
  • 1
  • 1
J. Does
  • 23
  • 1
  • 1
    As an aside, the convention is that interfaces are prefixed with `I`, so your `Killable` interface in idiomatic C# would be named `IKillable`. – Charles Mager May 01 '16 at 17:34

1 Answers1

0

You should define method Kill() in Entity class. If you don't need implementation of this method in abstract class, the method Kill() in Entity should be abstract:

abstract class Entity : MapObject, Killable
{
    public abstract void Kill(); // or without "abstract" if method needs a body
}
Roman
  • 11,966
  • 10
  • 38
  • 47