Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create Instance Of Class Through Method Call Only?
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01464302
Message ID:
01464306
Views:
50
>Is it possible to prevent a class from being instantiated from outside a class? Sort of like a factory pattern. I would like to change my
>project so that new instances can only come through a method call.
>
>How do I do this?

If you make constructor of this class private, then you would not be able to instantiate the class from outside.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform