in some sites it's mention ,we can create one static constructor within a class .
and in some other sites it mention more than one staic constructor.
which is correct???
in some sites it's mention ,we can create one static constructor within a class .
and in some other sites it mention more than one staic constructor.
which is correct???
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sandeep Singh ShekhawatPosted Oct 9, 2012, 4:34 AM
When we call any property/method of static class we can not decide which constructor call only default constructor is called so what's need of other constructor.
Static constructor use to intilize static member of class and static member have only one value in a session in IIS so what's purpose of another static constructor.
So in short we can define only one static constructor in an single static class.
Thanks
Sandeep
VulpesPosted Oct 9, 2012, 5:17 AM
A class or struct can have (at most) one static constructor.
This cannot have any parameters or an access modifier and cannot be called directly - it is called automatically by the system before any other static member is accessed or instance constructor is invoked.
Kunal VaishyaPosted Oct 9, 2012, 2:23 AM
you can create as per requirement but using overload methods concept using passes different parameters.