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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -