views:

75

answers:

3

The below seem to be very similar:

  • What differences are there between a static and private ctor in a class?
  • Furthermore, what's the difference between a singleton and an instance class with a static or private constructor?
+1  A: 

Both static contructor (see Fourth version) and private constructor can be used to implement singelton design pattern

Oren A
@Timwi: Thanks, wasn't aware of that option.
Oren A
A: 

A static constructor is called the first time the class type is mentioned in any way. Could be used for filling static dictionaries, for example. These constructors can not be called explicitly.

Private constructors on the other hand, can only be called from within the class itself. This can be used to restrict or monitor the creation of new instances of that class, by creating factory methods, for example.

As for the singleton question, Oren A about summed that up.

Joachim VR
A: 

You can get more information about static class and sigleton usage in this link

Polaris