Uses for static generic classes?

前端 未结 9 1730
猫巷女王i
猫巷女王i 2020-12-08 10:11

What are the key uses of a Static Generic Class in C#? When should they be used? What examples best illustrate their usage?

e.g.

         


        
9条回答
  •  春和景丽
    2020-12-08 10:48

    You're right: they're not much use. Perhaps there are some rare cases that are exceptions, though. For example, what if the class was a type-specific repository, as in Justin's example, but kept a static collection as a cache? In general, if it contains state, not just methods, there may be a point to this.

提交回复
热议问题