SharedInstance<T>

SharedInstance is actually the most basic type of generic Singleton implementation that's been around in the C# community. This implementation was both simple and efficient. But, it violated the definition of a Singleton by depending on the presence of a public constructor and thereby allowing additional instances to be created. Therefore, I have refrained from calling this a Singleton resorted to the term SharedInstance.

E.g:

SharedInstance<User>.Instance.Login("admin", "password");
 
User employee1 = new User();
employee1.Username = "emp001";
employee1.Password = "pass001";
employee1.Save();
Back to top
sharedinstance.txt · Last modified: 2008/12/12 16:04 by sameeraperera