vendredi 17 mai 2019

What to do if I want all objects that implement an interface to have a certain field

In short, I want all of my objects that implement an interface to have a common field. I have an interface called IMovable and I want every object that implements it to have a private field called _hasMoved. What would be the best way to solve this?

I have tried making an abstract class, but I want to implement multiple interfaces. I've also considered using a property, but that seems unreasonable, as I don't want any extra functionality.

Aucun commentaire:

Enregistrer un commentaire