why we use constructer in c# ?
where we use it in realtime?
please send the answers for both questions!
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pradeep ShetRank #595 · 4K reputationPosted Jun 25, 2015, 11:07 AM EDT
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Jun 25, 2015, 7:27 PM EDT
Bhushan BhasmeRank #2,348 · 604 reputationPosted Jun 25, 2015, 7:27 PM EDT
A class may have multiple constructors that take different arguments. Constructors enable the programmer to set default values, limit instantiation, and write code that is flexible and easy to read.
When we create a object of class constructor gets automatically called.
There Are Three Types Of Constructors
1]Parameterless constructor
when You write any class and creates its object and provide parameterless constructor but donot provide any parameters then parameterless constructor gets called.
2]Parameterised constructor
when You write any class and creates its object and provide Parameterised constructor but provide any parameters then parameterised constructor gets called.
2]Default constructor
when You write any class and creates its object and do not provide constructor Default constructor gets called.
Hope this will help You
Jignesh TrivediRank #16 · 50.3K reputationPosted Jun 25, 2015, 7:50 PM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Jun 25, 2015, 8:12 PM EDT
Jaipal ReddyRank #588 · 4.1K reputationPosted Jun 25, 2015, 8:46 PM EDT