Static and non-static classes are basically the same, but there is one difference: Static classes cannot be instantiated.
Key features of static classes:
- Contains only static members.
- cannot be instantiated.
- is sealed.
- Cannot contain instance constructors.
A non-static class can contain static methods, fields, properties, or events.Even if you do not create an instance of the class, you can call a static member in that class. No matter how many instances are created on a class, its static methods and properties cannot access non-static fields and events in their containing types, and cannot access the instance variables of any object (unless explicitly passed in method parameters).
It is more common to declare a non-static class with some static members, rather than declaring the entire class as a static class. static fields have two common uses: one is to record the number of objects that have been instantiated, and the other is to store values that must be shared across all instances.
Static methods can be overloaded but cannot be overridden because they belong to a class and do not belong to any instance of the class.
Although a field cannot be declared asstatic const, but the behavior of the Const field is essentially static. Such fields are types, not instances of types. classname.membername notation that's used for static field S. " As a result, you can use classname.membername notation to access the Const field as you would for a static field. object instances are not required.
c# does not support static local variables (variables declared within the scope of the method).
Static members are initialized before they are accessed for the first time and before a static constructor is called, if there is one.
If your class contains static fields, provide a static constructor that initializes these fields when the class is loaded.
Static class and Static class members