There is no reason to return instance to a static class
(if the class is static, there is no instance).
You can access the class everywhere, why return an instance
? I can not imagine any reason for this.
Using a static class
To use a static class, simply write it as shown below:
MyStaticClass.MyMethod(); Int32 callCount = MyStaticClass.CallCount;
As you can see, it does not even make sense to declare a variable, because it will look like this:
MyStaticClass msc = MyStaticClass.Instance(); msc.MyMethod(); Int32 callCount = msc.CallCount;
If you want to have a shorter name that you can simply use:
using MSC = MyNamespace.MyStaticClass;
source share