When would I want to model a class with a private ctor?

Posted by dotnetdev on Stack Overflow See other posts from Stack Overflow or by dotnetdev
Published on 2011-01-16T21:40:16Z Indexed on 2011/01/16 21:53 UTC
Read the original article Hit count: 148

Filed under:

Hi,

I've seen plenty of classes in .NET which have private constructor (Stream is one of them I think). When would I want to model a class like this?

I keep thinking that if my class has no internal state/fields, then I can make it have a private constructor.

Am I on the right track with this idea? I can understand the use of a factory (I've run into the tipping point a few times), but not with a private constructor class.

Thanks

© Stack Overflow or respective owner

Related posts about c#