Question: I am trying to solve a simple OOPs problem. When I have to create few weapons and each weapon has a primary action and that primary action can be performed by a mouse click. Example for a shotgun it is shooting and for Katana is swinging it. Below my classes are.

```
public interface IShootable
{
    void TakeShot();
}
public interface ISwingable
{
    void Swing ();
}

public class ShotGun : IShootable
{
    public void TakeShot()
    {
    }
}
public class Kanata : ISwingable
{
    public void Swing ()
    {
    }
}   

```

Each weapon has implemented different interface for their primary actions. (I'm not sure that I can create an abstract class, from which I can inherit these concrete classes. It seems not substitutable for two different type of weapons.)

What I wanted to achieve is in runtime when user selects one of the weapons, the user gets the right action on mouse click. For shotgun it is `TakeShot()` and for Katana it is `Swing()`.

What I have to do adopt that. Or I should restructure the classes in some other way.

Answer: 
Both classes can both implement a third interface - `IWeapon`, with an `Attack`/`Use` method:

```
public interface IWeapon {
    void Attack();
}

public class ShotGun : IShootable
{
    void IWeapon.Attack() {
        TakeShot();
    }

    public void TakeShot()
    {
    }
}
public class Kanata : ISwingable
{
    public void Swing ()
    {
    }

    void IWeapon.Attack() {
        Swing();
    }
}  

```

Note that I have [explicitly implemented](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/interfaces/explicit-interface-implementation) the `IWeapon` interface here. You don't have to do it explicitly, and can still do it the "normal way". but I prefer it this way. This way, when you have a `Katana` object, only `Swing` is visible, but not `Attack`. I just feel that having both methods visible is confusing.

Also note that `IWeapon` is unrelated to `ISwingable` and `IShootable`, because swingable things (tennis racket) and shootable things (water pistol) are not necessarily weapons.
My preference would be what @Riki suggests and create an interface that all weapons inherit `IWeapon` with a single method `IWeapon.PerformPrimaryAction()`. However if you don't like that you could create a "base" interface that all weapon interfaces derive from, then at runtime use casting, `is` or `as` to determine which weapon you have:

```
public interface IWeapon {};

public interface IShootable : IWeapon
{
    void TakeShot();
}

public interface ISwingable : IWeapon
{
    void Swing ();
}

public partial class YourGameClass
{
    public void DoTheAction (IWeapon weapon)
    {
        if (weapon is IShootable)
            (weapon as IShootable).TakeShot();
        if (weapon is ISwingable)
            (weapon as ISwingable).Swing();
    }
}

```