Differences between 1.java and C # static member invocation
Static, which is a shared resource, is created when the class is loaded.
Java can be invoked through an instance, or by a class name. member name, but it is generally preferable to use the class name. Member this way, because static members belong to the class, not to specific objects
C # can only be called by the class name. Member, and cannot be
To invoke with an instance
2.c# Static constructors and construction code blocks in Java, static code blocks
Features of C # static constructors:
1) Static constructors do not need to be called manually, the system automatically calls
2) A static constructor is executed when a static member is first used or initialized to an object, and takes precedence over the constructor or the invocation of a static member.
3) Static constructors cannot add access modifiers and parameters, default to Private
Grammar:
Static class name ()
{
Code
}
Java Static code block features:
1) Static code block does not need to be called manually, the system automatically calls
2) A static code block executes at the first time the class is loaded and executes only once, so the precedence constructor executes (constructor: used when instantiating)
3) Static code block cannot add access modifiers and parameters
Grammar:
static{
Code
}
Java Construction code block features:
1) Initialize the object. The object runs as soon as it is established and takes precedence over the constructor.
2) Difference from constructor function
--the difference between constructing a block of code and constructing a code block is to initialize all objects uniformly, and constructors to initialize the corresponding objects.
--The function of constructing code blocks: It is to extract the public information from all the construction methods.
For example a child born unified cry
3) Syntax:
{
Code
}
STATC static calls differ in C # in Java, static constructors for C # and construction code blocks in Java, static code blocks