P
PokerMan
I usually do singleton implementatios like this:
static readonly myClass instance = new myClass ();
public static myClass Instance
{
get { return instance; }
}
static myClass(){}
but in this situation my constructor has variables and making a static
constructor will not allow for these vars. So i am doing it like this:
static readonly myClass instance = new myClass ();
public static myClass Instance
{
get { return instance; }
}
private myClass ()
{
_someObj = new SomeClass();
_someObj .Completed += OnComplete;
}
I see no problem myself, as the statc instance is created, triggers the
constructor, initliaises the static instance and then i always ref the
static instance. So surely a static constructor is actually unneeded? I just
want to verify i am right in my assumption and there is not something abt a
signleton that i am unaware of.
Thanks
static readonly myClass instance = new myClass ();
public static myClass Instance
{
get { return instance; }
}
static myClass(){}
but in this situation my constructor has variables and making a static
constructor will not allow for these vars. So i am doing it like this:
static readonly myClass instance = new myClass ();
public static myClass Instance
{
get { return instance; }
}
private myClass ()
{
_someObj = new SomeClass();
_someObj .Completed += OnComplete;
}
I see no problem myself, as the statc instance is created, triggers the
constructor, initliaises the static instance and then i always ref the
static instance. So surely a static constructor is actually unneeded? I just
want to verify i am right in my assumption and there is not something abt a
signleton that i am unaware of.
Thanks