草庐IT

SingletonExample

全部标签

c# - 带参数的单例

我需要一个单例类来实例化一些参数。我现在的做法是:classSingletonExample{privateSingletonExamplemInstance;//othermembers...privateSingletonExample(){}publicSingletonExampleInstance{get{if(mInstance==null){thrownewException("Objectnotcreated");}returnmInstance;}}publicvoidCreate(stringarg1,stringarg2){mInstance=newSinglet

c# - 带参数的单例

我需要一个单例类来实例化一些参数。我现在的做法是:classSingletonExample{privateSingletonExamplemInstance;//othermembers...privateSingletonExample(){}publicSingletonExampleInstance{get{if(mInstance==null){thrownewException("Objectnotcreated");}returnmInstance;}}publicvoidCreate(stringarg1,stringarg2){mInstance=newSinglet