c# - Interfaces cannot declare types -
i have abstract class in api used methods in assembly. class has nested enum defined within it, bit this:
abstract public class thing { public enum status { accepted, denied, pending }; abstract public status status { get; private set; } etc... }
i decided improve design if thing interface. can't this:
public interface thing { enum status { accepted, denied, pending }; status status { get; } etc... }
this produces error message "interfaces cannot declare types." however, if move definition of enum outside of interface, firstly i'd breaking encapsulation (the status type belongs thing , meaningless on own) , more importantly have go , modify code in many other assemblies utilize this. can think of solutions?
as error indicates, have pull definition of status
outside of interface. understand breaks encapsulation, there's no way around this. suggest alter name of status
indicates strong relation thing
-- thingstatus
should trick.
enum thingstatus { accepted, denied, pending }; public interface thing { thingstatus status { get; } etc... }
c#
No comments:
Post a Comment