I believe you are referring to the simpler version of ..

// .NET Singleton
sealed class Singleton
{
   private Singleton() {}
   public static readonly Singleton Instance = new Singleton();
}


This is ok providing you dont care if beforefieldinit is set. This
will cause the JIT to load the static constructor before its actually
needed (creating the explicit static constructor as in #5 prevents
this).

For a singleton like this its of no real consequence but if you had
alot of logic which needed to happen during construction you may
really want to consider the other which says "dont contruct it until
something tries to use it"

Cheers,

Greg

On 7/9/07, Miika MƤkinen <[EMAIL PROTECTED]> wrote:
Hi guys,
Which singleton implementation do you normally use? I've been using number
five from http://www.yoda.arachsys.com/csharp/singleton.html but reading
http://msdn2.microsoft.com/en-us/library/ms954629.aspx I'm understanding
that a simpler implementation works just the same?

Cheers,
Miika

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com



--
Studying for the Turing test

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to