Is it possible to wrap a C# singleton in an interface?

后端 未结 4 877
挽巷
挽巷 2021-02-20 05:28

I currently have a class in which I only have static members and constants, however I\'d like to replace it with a singleton wrapped in an interface.

But how can I do th

4条回答
  •  广开言路
    2021-02-20 05:35

    You can make all the other members of your singleton implement corresponding members in an interface. However, you are correct that the Instance property cannot be part of the interface since it is (and must remain) static.

提交回复
热议问题