Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have multiple classes in one project suppose c1,c2,c3.
I want to make single instance of c1 which can be used in both c2 and c3.
What should i do?
Posted

Use Singleton Class.. and instantiate only once and use it for all your subsequent classes.

There are two approaches. Singleton or Static.
Best explanation is provided in below link check it out and apply as per your need.

http://www.dotnetperls.com/singleton-static[^]
 
Share this answer
 
v2
SingelTon is a Designing pattern that is used to achieve what you are trying to do here.
Refer this link[^] and this[^].

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900