In a static class, all the members that are contained are "static members"
Not all static members must be unloaded in a static class
Static members are "classes", not specific "objects", so access to static members cannot be accessed through objects (objects. Property name), you can access static members directly through the class name.
Accessing the static member at any point in the program is actually accessing the same piece of memory, and there is a place where the value is changed, and the values obtained everywhere are changed.
The data for a static member is not freed until the program exits, and the instance object can perform garbage collection as long as it is used.
Static members in a class are initialized the first time a static class is used.
Features of static constructors:
Static constructors cannot be called manually, but are called automatically the first time a static member is used, so you cannot add an access modifier to the static constructor, which defaults to Peivate
Because a static constructor is automatically called by the system, it does not require (cannot) add any parameters
Static constructors execute only once
Executes when a static class or static member is used for the first time
Polymorphic
polymorphic role: The different sub-class objects are considered as the parent class, you can block the differences between different sub-class objects, write generic code, make a general change to adapt to the changing needs
Another way to type conversions (AS)
Type conversions are performed by as, even if the conversion fails to report an exception, but instead returns a null
Person P=new Student ();
Student s=p as Student;
if (s!=null)
{
Console.WriteLine ("Conversion succeeded!") ")
}
Else
{
Console.WriteLine ("Conversion failed! ")
}
static classes for C # Basic Learning (0708)