6
Reply

Why a static contructor in C# are not overloaded?

Upamanyu Roy Choudhury

Upamanyu Roy Choudhury

11 years ago
1.3k

Dear All,

We all know static condtructors in C# are used to initialize the static data members within a class.

But it cannot be overloaded.

My question is that why this feature is not supported?

My understanding::

Is it just because that we cannot associate an object with the static constructor like the way we do it in case of non static ones by explicitly calling them while crating an instance of the class. See the following

ClassEmployee objClassEmployee = new objClassEmployee("Emp001","Upamanyu",30000); // explicitly calling the overloaded contrcutor

But we cannot do like that

StaticCons();
StaticCons(("Emp001","Upamanyu",30000); // we do not call static construtors, it gets called before the first instance of the class gets referenced.

So the overloaded feature is off in case of static ones???

Please provide your views on it.


Many Thanks,
Upamanyu

Answers (6)