See what is Static Class, I have worked hard for a long time, I have been in a abstract seal Class, and I have already raised this problem on 9CBS, but I didn't get resonance. The reply I got is like this:
Is Abstract and Sealed? Defining the purpose of Abstract is abstract base class, SEAL means that the entity class that cannot be inherited is completely two things, how can I use it together? Abstract It is necessary to be inherited, and SeaD indicates that it cannot be inherited, these two are contradictory, how can I use it together?
By viewing the IL code, we will find that static class is actually Abstract Sealed Class, but the compiler is checked in the compiler to check the Static Class's member modifier.
Let's guess the idea of MS developers: their purpose is to get the effect of Abstract Sealed Class, but it is very angry for semantic contradictions. Everyone wants to get a beautiful solution, so it is C # 2.0 new A static keyword, perfectly solved this problem.
Maybe someone will ask: Why isn't Static Class = Abstract Class Static MEMBER LIMIT to add SeaD restrictions? The reason is to inherit a class and rewrite a class with only Static members. Why do you say this? Because Static is inevitably not virtual, what can I use?
Static class has a limit, that is, can only be inherited from System.Object, why there will be this restriction, the reason and the above.
Every time I mention the static keyword, I remembered Static Constructor, thank MS developers to provide such a good feature. However, C # provides Static Constructor without providing Static Destructor, but Jeffery Richter in Applied Microsoft .NET Framework Program provides us with a way to achieve the same effect through System.AppDomain.domainunloy A event.
It is to pay attention to using Static Constructor to throw any exceptions to cause this type until it is available until you reload AppDoamin, so be more careful, and the STATIC Contructor is easy to have two type deadlocks, in writing code It must be clear.
Length.
Rustle Liu, http://ms.mblogger.cn/rustle/