Hi....
Ques: Hello all of you now i have write a program of constructor but problem is C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write? please explain....
C# provides a default constructor
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Manoj Singh PanwarRank #529 · 4.6K reputationPosted Dec 17, 2011, 1:03 AM EST
you have to write only one constructor i.e. the one in which you are using string parameter. This is because you need not have to bother bout the default constructor, its task will be occupied with the parameterized constructor so just write the parameterized one. It will do the job.
--------------------------------------------------------------
mark and accept the answer to be correct if it helps you.
VulpesRank #55 · 29.2K reputationPosted Dec 17, 2011, 3:14 AM EST
So, if you are providing a constructor which takes a string as a parameter and you want one which takes no parameters as well, then you will have to code it yourself i.e. you will need to code two constructors in total.