C
Cybertof
Hello,
I have a simple question :
In the below code, why do i get an (ERROR) saying
"An object reference is required for the nonstatic field, method, or
property 'mLockeEnv3'"
I don't understand why mLockeEnv3 should be static.....
Also, what is the difference betwenn mLockeEnv & mLockeEnv2 as both
declarations are working....
public class CLockeMain
{
public static CLockeEnv mlockeEnv;
public static CLockeEnv mlockeEnv2 = new CLockeEnv();
public CLockeEnv mLockeEnv3;
static void Main()
{
mLockeEnv = CLockeEnv.GetInstance();
mLockeEnv2 = CLockeEnv.GetInstance();
mLockeEnv3 = CLockeEnv.GetInstance(); (ERROR)
}
}
Note :
CLockeEnv is a singleton class with an internal private member pointing
to itsel. GetInstance creates the object or returns the existing
instance.
I have a simple question :
In the below code, why do i get an (ERROR) saying
"An object reference is required for the nonstatic field, method, or
property 'mLockeEnv3'"
I don't understand why mLockeEnv3 should be static.....
Also, what is the difference betwenn mLockeEnv & mLockeEnv2 as both
declarations are working....
public class CLockeMain
{
public static CLockeEnv mlockeEnv;
public static CLockeEnv mlockeEnv2 = new CLockeEnv();
public CLockeEnv mLockeEnv3;
static void Main()
{
mLockeEnv = CLockeEnv.GetInstance();
mLockeEnv2 = CLockeEnv.GetInstance();
mLockeEnv3 = CLockeEnv.GetInstance(); (ERROR)
}
}
Note :
CLockeEnv is a singleton class with an internal private member pointing
to itsel. GetInstance creates the object or returns the existing
instance.