Why we give Constructor name same as the Class name?
Why we give Constructor name same as the Class name?
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.
VulpesPosted Sep 18, 2014, 8:32 AM
For example VB.NET uses New(), CIL uses .ctor() and Apple's new Swift language uses init().
However, C++ and Java both use the name of the class and when C# was invented the designers wanted it to feel comfortable to users of those languages. So, I guess it was an easy decision for them to do the same.
As Arunava says, it's still easy for a developer to pick out constructors from the rest of the code though perhaps not quite as easy as if they'd used the same constructor name for all classes.
Arunava BhattacharjeePosted Sep 17, 2014, 11:52 PM