I have an abstract class in an API that is used by methods in another assembly. The class has a nested enum defined inside it, a bit like this:
abstract publ
Oh yes, the solution is to use an abstract class if you need such implementation. Abstract classes are not a bad design and are certainly useful in situations like this.
If you insist on using interfaces, I'm afraid you'd have to go with the solution from p.s.w.g and break a rule or two (those are just guidelines anyway, really).
You must declare a type as public in namespace or outside of namespace and then declare a method of this type in the interface
abstract
class and interface
are different things. abstarct
class is abstraction, higher than your domain model and interface is the contract (behavior) of your domain entity. You can use both in your solution as necessary. In concrete scenario status
is not behavior it just state of entity. I think abstract class is more reliable choice.
As the error indicates, you just have to pull the definition of Status
outside of the interface. I understand that it breaks encapsulation, but there's really no way around this. I suggest you change the name of Status
to something which indicates a strong relation to Thing
-- ThingStatus
should do the trick.
enum ThingStatus { Accepted, Denied, Pending };
public interface Thing
{
ThingStatus status { get; }
etc...
}