O'Reilly logo

C# Design Patterns: A Tutorial by James W. Cooper

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. The Singleton Pattern

The Singleton pattern is grouped with the other Creational patterns, although to some extent it is a pattern that limits, rather than promotes, the creation of classes. Specifically, the Singleton assures that there is one and only one instance of a class and provides a global point of access to it. There are any number of cases in programming where you need to make sure that there can be only one instance of a class. For example, your system can have only one window manager or print spooler, or a single point of access to a database engine. Your PC might have several serial ports but there can only be one instance of “COM1.”

Creating Singleton Using a Static Method

The easiest way to make a class that can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required