c# - Why public static property returns an object? -
i looking through https://github.com/verbalexpressions/csharpverbalexpressions , there found that, there class verbalexpressions , static property defaultexpression
public class verbalexpressions { public static verbalexpressions defaultexpression { { return new verbalexpressions(); } } }
and object created like
verbalexpressions verbex = verbalexpressions.defaultexpression;
i novice c# programmer , trying understand, why creating objects this? not implementing singleton pattern guess.
what cause type of implementation ? can please?
the singleton-pattern class should have implementing this
public singletonclass { private singletonclass instance; public static getinstance { { if (instance == null) { instance = new singletonclass(); } return instance } } }
Comments
Post a Comment