B
babylon
is it normal to do something like:
public MYCLASS
{
private static MYCLASS defaultInstance = null;
public static MYCLASS GetDefaultInstance()
{
return MYCLASS.defaultInstance;
}
public MYCLASS(int arg1, string arg2)
{
// Init...
...
MYCLASS.defaultInstance = this;
}
}
as all other component can get a reference to MYCLASS easily
(MYCLASS.getDefaultClass())
if I don't do it this way
I need to pass a reference of MyClass to the component that will use it....
or there are better solution available in C# that is better than the above
solution?
public MYCLASS
{
private static MYCLASS defaultInstance = null;
public static MYCLASS GetDefaultInstance()
{
return MYCLASS.defaultInstance;
}
public MYCLASS(int arg1, string arg2)
{
// Init...
...
MYCLASS.defaultInstance = this;
}
}
as all other component can get a reference to MYCLASS easily
(MYCLASS.getDefaultClass())
if I don't do it this way
I need to pass a reference of MyClass to the component that will use it....
or there are better solution available in C# that is better than the above
solution?