Name of the blog

Short description of the blog

Difference between static class and singleton pattern

  • Singleton object stores in Heap but, static object stores in stack
  • We can clone the object of Singleton but, we can not clone the static class object
  • Unlike static classes, we can use singletons as parameters or objects.
  • we can implement interface with Singleton class but not with Static class.
  • Singleton class follow the OOP(object oriented principles) but not static class
  • Singleton class maintains state. It is thread safe.
  • we can dispose the objects of a singleton class but not of static class

The difference between the Singleton and Static is Singleton Class can have value when Class object instantiated between server and client, such a way if three client want to have a shared data between them Singleton can be used. Static are always just shared and have no instance but multiple references.

What is difference between static class and sealed class

Sealed classes:

  1. Can create instances, but cannot inherit
  2. Can contain static as well as nonstatic members.

 

Static classes:

  1. Can neither create their instances, nor inherit them
  2. Can have static members only.

 

Cheap MLB Jerseys maillot de foot pas cher www.fotballdrakter.org