In this series on learning singleton pattern, we learned lazy initialization and eager initialization with practical examples. We also learned why it is necessary to make the singleton class sealed with the sealed keyword. In this article, I’ll try to explain the differences between static and singleton class. We will also see where to use static class and where to use singleton classes.
Continue reading “Singleton Design Pattern In C# – Part Three (Static vs Singleton)”
In the previous article on learning singleton pattern, we discussed what is singleton design pattern, when is it needed and what problems it solves. We also discussed how to create a basic singleton class step by step and how to enhance that class to be thread-safe with the help of locking and performance effective with the help of double check locking. In this article, we’ll discuss Lazy initialization, the lazy keyword, why to make singleton class a sealed class, and what are the differences between singleton and static class. Before we start, I strongly recommend you go through my last article.
Continue reading “Singleton Design Pattern In C# – Part 2 (Eager and Lazy Initialization in Singleton)”
I always wanted to write on Singleton design pattern in C#. Though there already are many posts available on Singleton design pattern, I’ll try to cover this topic in the most simplistic and easy to understand way.
Continue reading “Singleton Design Pattern in C# – Part 1”