Static Class and Class Member, static class member
1. Static classes only contain static members
2. Unable to instantiate
3. It is sealed and cannot be inherited
4. There can be a static constructor that cannot contain the instance constructor.
5. Access static members directly with class names and members
6. A common use of static classes may be to create a mathematical library containing a set of mathematical methods.
Public static class MyMath {public static float PI = 3.14f; public static bool IsOdd (int x) {return x % 2 = 1 ;}}
A. Non-static classes can contain static methods, fields, attributes, or events.
B. Static methods and attributes cannot access non-static fields and events.
C. The const field is static in nature.
Public class Automobile {private static int Val; private const int NumberOfWheels = 4; // const handles public static void Print () {Console. writeLine ("The automobile have {0} wheels. ", NumberOfWheels);} public static int Size // only static fields can be accessed {get {return Val;} set {Val = value ;}}}