Why do we need a private constructor?

Posted by isthatacode on Stack Overflow See other posts from Stack Overflow or by isthatacode
Published on 2010-04-06T14:56:09Z Indexed on 2010/04/06 15:03 UTC
Read the original article Hit count: 147

Filed under:
|
|

if a class has a private constructor then it cant be instantiated. so, if i dont want my class to be instantiated and still use it, then i can make it static.

what is the use of a private constructor ?

Also its used in singleton class, except that, is there any othe use ?

(Note : The reason i am excuding the singleton case above is because I dont understand why do we need a singleton at all ? when there is a static class availble. You may not answer for my this confusion in the question. )

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about .NET