This MSDN article states that static classes should be declared as sealed and abstract. I was under the impression that static classes were already sealed. Why would you also need to declare a static class as sealed?
This MSDN article states that static classes should be declared as sealed and abstract. I was under the impression that static classes were already sealed. Why would you also need to declare a static class as sealed?
I think the pertinent bit from that article is:
"Do declare static classes as sealed and abstract, and add a private instance constructor, if your programming language does not have built-in support for static classes."
Remember, the .NET framework supports a lot of different languages.
C# v1 did not allow 'static' keyword on class. So if you have a class with only static methods, it was suggested to declare it 'sealed', 'abstract' and make constructor private. This means that no one can instantiate your class or try to inherit from it. [It doesn't make sense to inherit from a class which has only static methods.]
C# v2 allowed the static keyword on a class so you don't have to use the above trick to enforce correct usage.