I'm changing the inner implementation of a project.  In order to do so, I've created an interface that will be implemented in 2 different ways.One of this ways is by class A, which is a wrapper for an outside class (class B) from a .dll file (a product of other team).Class B is a private a member of class A.  Class B ctor takes an argument, which does not change during the run of my application. It needed to be created only once, and to stay available for class A everywhere in the code.Class A is an implementation of interface.  It use the capabilities of class B in order to implement it's functions, and obviously needed to be available also everywhere in the code. I've concluded that:Class A has to be:explicitly created once (hence, not static)  only once, (because I need B to be created only once.) accessible from anywhere in the codehave a member (B) that must initialized once, and only once (private member, needed only inside class A)Concerning condition #4, ideally I would like to initialize B in the constructor.A bit similar to singleton pattern, with the exception of wanting to initialize a member in the constructor.I've come to a solution, and would like to get feedback.public sealed class A{   private static SomeClass B = null; // the must initialized only once member   // setting B:   private void setB(int i)   {      B = new SomeClass(i);   }   // ctor   public A(int i)   {      if(B == null)         setB(i);      else throw new Exception(An instance of A can be created only once);   }     }The idea is to assign the class to static object at the beginning of the code.  It's not very neat, but it compiles and seems to do the job just right.  I don't use singleton since it won't be possible to initialize the member in the ctor.  By the way, thread safety is not a concern here.   SomeClass needed only inside class A. SomeClass comes from dll, and class A kind of wrapping it.  A does answering cross-cutting concern, it is an implementation of Interface used all over the code. I've tried to implement singleton, but as much as I tried it didn't answer my needs.
Singleton-like pattern for a project
c#;singleton