No, because you cannot invoke a static constructor explicitly, it is invoked implicitly by the run time before the objects are instantiated. Also, you cannot pass any parameters to a static constructor(its always parameter less) therefore it cannot be overloaded.
1.It can only access the static member(s) of the class.
Reason : Non static member is specific to the object instance. If static constructor are allowed to work on non static members it will reflect the changes in all the object instance, which is impractical.
2.There should be no parameter(s) in static constructor.
Reason: Since, It is going to be called by CLR, nobody can pass the parameter to it. 3.Only one static constructor is allowed.
Reason: Overloading needs the two methods to be different in terms of method/constructor definition which is not possible in static constructor.
4.There should be no access modifier to it.
Reason: Again the reason is same call to static constructor is made by CLR and not by the object, no need to have access modifier to it
No comments:
Post a Comment