Global vs Singleton in .NET

前端 未结 6 1413
清酒与你
清酒与你 2021-01-06 00:10

I have a very common situation here. And for years I haven\'t found if what i am doing is RIGHT by industry standards.Consider an application which connects to the database,

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-06 00:33

    If all you're storing is a string (possibly along with a bunch of other global application settings), I would just use a static class with a bunch of properties to hold all that. A singleton is more code & maintenance work, but it's unnecessary work in this case, since your properties class isn't going to DO anything; just hold things.

提交回复
热议问题