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....
Loading

VulpesPosted Dec 17, 2011, 8:14 AM
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.
Manoj Singh PanwarPosted Dec 17, 2011, 6:03 AM
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.