These static constructors are correct ? class A { statc intA() { } static A(int x,int y) { } static A(int x) { } }
Rajesh Singh
Constructor don't have return type
Please see below class A { statc intA() { Correct } static A(int x,int y) { Incorrect } static A(int x) {Incorrect } }Static constructor automatically invoked/called by CLR so access modifer or parameters are not allowed
static constructor does not contain any parameter or access modifier or return type.
1. Incorrect because static constructor will not have return type 2&3. Incorrect because static constructor must be parameterless
Your class is not static how should you define constructor its compile time error.
Your class is not static it gives you compile time error..
Static constructors should be parameter less
Static Constructor must be parameter less
Static constructor will automatically be invoked only once. It happens either creation of the first object or accessing its static members. Any way we cannot explicitly invoke the static constructor so access modifer or parameters are not allowed
no
A static constructor does not take access modifiers or have parameters.