I have seen a singletone code that uses a function without parentheses. i wanted to know is there any difference between a function without parentheses and a function with parentheses that takes no arguments.
Here in the code public static MySingleton Instance
has no parentheses:
(The code is for unity by the way and written in c#)
public class MySingleton
{
private static MySingleton instance;
public MySingleton ()
{
if (instance != null)
{
Debug.LogError ("Cannot have two instances of singleton.");
return;
}
instance = this;
}
public static MySingleton Instance
{
get
{
if (instance == null)
{
new MySingleton ();
}
return instance;
}
}
}