- Class constructor (static constructor)
- Instance constructor (non-static constructor)
See example below.
public class StaticTestClass1(){
static StaticTestClass1(){
//Static members may be accessed from here
//Code for Initialization}
}
While creating a static constructor, a few things need to be kept in mind:
- There is no access modifier require to define a static constructor.
- There may be only one static constructor in a class.
- The static constructor may not have any parameters.
- Static constructor may only access the static members of the class.
No comments:
Post a Comment