Why do the constructors have to have the same class name?

0

Is it really necessary for the constructor to have the same name as the class?

    
asked by anonymous 30.10.2016 / 02:53

1 answer

3

Yes, it is. Language requires this by convention. It might not be, but it's like this.

Documentation . Also . Microsoft Documentation . If the specification were openly published I would post it here, but the excerpt from item 12.1 would be:

  

Constructors do not have names. A special declarator syntax is used to declare or define the constructor.

So this is the syntax adopted by convention, although formally it does not have an official name.

    
30.10.2016 / 03:33