2

What classes in the .NET Platform use the Singleton pattern?

Just want to take a look at them through Reflector and see how are implemented, and more than it, how Singleton can be used in different contexts.

Oscar Mederos
  • 28,017
  • 21
  • 79
  • 123

3 Answers3

2

Pretty much where you see Provider in the name. Especially in the FormsAuthenication and Membership parts of ASP.NET.

Daniel A. White
  • 181,601
  • 45
  • 354
  • 430
1

System.DBNull:

public sealed class DBNull 
{
   public static readonly DBNull Value;

   static DBNull()
   {
      Value = new DBNull();
   }

   private DBNull() {}
}
Mark Cidade
  • 96,194
  • 31
  • 221
  • 232
1

Definitely the Settings classes which derive from System.Configuration.ApplicationSettingsBase. Pretty much all the application/user scope settings are managed by singleton instances.

Teoman Soygul
  • 25,324
  • 6
  • 68
  • 79