Does c# supports destructors?
Answers were Sorted based on User's Feedback
Answer / praveen saxena
Yes and No,
C# supports destructors just to provide a familiar way fo
destructing objects for C++ developers. even syntax also is
same but internally its the dicpose method that does all
the work.
Even if you declare a destructor the compiler automatically
translates a destructor into an override of the
Object.Finalize() method. In other words, the compiler
translates the following destructor:
class Class1
{
~Class1(){}
}
Into the following code:
class Class1
{
Protected override void Finalize()
{
try{..}
finally { base.Finalize();}
}
}
I guess that makes things more clear.
| Is This Answer Correct ? | 6 Yes | 0 No |
Answer / k. amith kumar
Yes
Example:
class A
{
A(){} //Constructor.
~A(){} //Distructor.
.........
..........
}
| Is This Answer Correct ? | 5 Yes | 1 No |
Answer / vijay
yes.
when a objects created by Constructor are removed by
destructor
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / puneet
Desturctors are very much supported by c#. Internally a c#
destructor is converted to a finalize method call.
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / chinju
yes c# support destructor.it is used to delete object
explicitly.Dispose() is used for this.if we didn't write the
destructor explicitly it will call the default destructor ie
Finalize().always destructor is executed after the execution
of name space
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / mahesh
No, I didnt think distructor is supported by C# as far as
dispose() is concern it is used for clean up code like
finalize the object is distroyed automatically by garbage
collector
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / ashish gupta
i think it doesnt allow to use Destructor.
there is a method called Dispose() which automatically
calls destructor
| Is This Answer Correct ? | 2 Yes | 3 No |
What C# keyword class access modifier specifies that the class is concrete and CANNOT be derived from?
What is difference between the "throw" and "throw ex" in .net?
what is the lifespan of the items stored in viewstate ?
What are classes in c#?
What is overloading in c#?
Explain about Error handling and how this is done
How to make sure custom class supports deterministic finalization?
Why do we need static in c#?
I wish to create a windows application to perform a similar function as that of the "Search" which is provided to look for related files and folders in the System.. What steps must i follow??
What is getenumerator?
What is a Assembly?
What is a interface in c#?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)