>>>> public class BaseObject >>>> { >>>> private BaseObject() { } >>>> } >>>>>>>>to prevent other developers directly creating an instance of the class. I was hoping to sub-class from this and have the behaviour inherited by these classes. Seems that's not possible - in fact I can't sub-class from BaseObject at all because 'BaseObject is inaccessible due to it's protection level'. Any other way to achieve what I need (I don't like the idea of having to put private constructors in all the leaf classes)
namespace Test { public class MyObject { private MyObject() { } public static MyObject NewMyObject() { return new MyObject(); } } class Tester { static void Main(string[] args) { // Next line won't compile because of accessibility: //MyObject t = new MyObject(); //But you can do it this way: MyObject t = MyObject.NewMyObject(); } } }Or am I missing something,