Hi...
What is the Constructor and Destructor in C# ? How many type of constructor and Destructor with example ?
Thanks...
Loading
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
Prabhu RajaRank #861 · 2.6K reputationPosted Oct 19, 2011, 9:33 AM EDT
Check out the Collection of Articles :
http://www.c-sharpcorner.com/Search/?sKeywords=Constructor+and+Destructor+in+C#
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 18, 2011, 9:21 AM EDT
Please refer to this article on C# Corner:
http://www.c-sharpcorner.com/UploadFile/rajeshvs/ConsNDestructorsInCS11122005010300AM/ConsNDestructorsInCS.aspx
VulpesRank #55 · 29.2K reputationPosted Oct 18, 2011, 10:10 AM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Oct 18, 2011, 10:27 AM EDT
The important thing is that most classes do not need a desctructor. There is also the IDisposable inerface and the Finalize method; they are also not needed for most things. Also, developers experienced with C++ but not C# have a tendency to call GC.Collect when they don't need to.
The most likely palces that things like that are needed is when a class calls unmanged code. Managed classes will take care of themselves.
I assume you are familiar with C++, which is very precise about destruction. C# is quite imprecise about destruction and you must accept that.
Satyapriya NayakRank #47 · 31.5K reputationPosted Oct 19, 2011, 6:33 AM EDT
Please refer Our recommended articles section.
Thanks
Vineet Kumar SainiRank #257 · 9.8K reputationPosted Nov 26, 2011, 12:54 AM EST