Click here to Skip to main content
15,890,670 members
Home / Discussions / C#
   

C#

 
GeneralRe: find file in web Pin
harold aptroot16-May-09 6:16
harold aptroot16-May-09 6:16 
GeneralRe: find file in web Pin
Manas Bhardwaj16-May-09 6:17
professionalManas Bhardwaj16-May-09 6:17 
GeneralRe: find file in web Pin
michaelgr116-May-09 6:35
michaelgr116-May-09 6:35 
AnswerRe: find file in web Pin
MumbleB16-May-09 6:45
MumbleB16-May-09 6:45 
GeneralRe: find file in web Pin
michaelgr116-May-09 7:09
michaelgr116-May-09 7:09 
GeneralRe: find file in web Pin
michaelgr116-May-09 8:28
michaelgr116-May-09 8:28 
AnswerRe: find file in web Pin
S. Senthil Kumar16-May-09 9:11
S. Senthil Kumar16-May-09 9:11 
QuestionC++ virtual destructor in C#? Why not? Pin
devvvy16-May-09 2:23
devvvy16-May-09 2:23 
hello

Need clarification on why we have no C# virtual destructor - here's my understanding.

1. Unmanaged resources are freed by calling Dispose (true/false), managed resources are freed by call to Dispose(true).
2. Managed memory is freed by call to Dispose - Base class should mark Dispose virtual, Derived class should explicitly "override" base class Dispose and "Base.Dispose" should be called in Derived.Dispose (this way both Derived/Base Dispose are called in chain)

Question:
1. Should we make Base.Finalize (~Base really in C# syntax) virtual? Should we implement Derived.Finalize (~Derived in C# syntax)?
2. C++ destructor is C# destructor (or Finalizer) - now SINCE we really want to release resource (expensive ones in particular) in Dispose (deterministically, unlike ~Derived or ~Base), what really I'm asking is, why not "Virtual destructor" same style as C++: http://www.codersource.net/cpp_virtual_destructors.html[^]

In C++, if you declared destructor virtual, and "delete oDerived", BOTH destructor from Base and Derived are invoked (~Derived then ~Base). Why is this NOT the behavior in C#? That you need to call Base.Dispose explicitly in Derived.Dispose, relying on programmer to make sure both are called? Seems like C++ virtual destructor is cleaner?

Thanks

REF:
http://www.codersource.net/cpp_virtual_destructors.html[^]
http://msdn.microsoft.com/en-us/library/b1yfkh5e(VS.71).aspx[^]

dev

AnswerRe: C++ virtual destructor in C#? Why not? Pin
S. Senthil Kumar16-May-09 4:45
S. Senthil Kumar16-May-09 4:45 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
devvvy16-May-09 5:37
devvvy16-May-09 5:37 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
S. Senthil Kumar16-May-09 9:01
S. Senthil Kumar16-May-09 9:01 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
N a v a n e e t h16-May-09 7:30
N a v a n e e t h16-May-09 7:30 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
S. Senthil Kumar16-May-09 8:47
S. Senthil Kumar16-May-09 8:47 
AnswerRe: C++ virtual destructor in C#? Why not? Pin
Mark Salsbery16-May-09 6:41
Mark Salsbery16-May-09 6:41 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
devvvy16-May-09 8:02
devvvy16-May-09 8:02 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
Mark Salsbery16-May-09 8:08
Mark Salsbery16-May-09 8:08 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
devvvy16-May-09 8:10
devvvy16-May-09 8:10 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
Mark Salsbery16-May-09 8:17
Mark Salsbery16-May-09 8:17 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
S. Senthil Kumar16-May-09 9:08
S. Senthil Kumar16-May-09 9:08 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
Mark Salsbery16-May-09 9:20
Mark Salsbery16-May-09 9:20 
AnswerRe: C++ virtual destructor in C#? Why not? Pin
Guffa16-May-09 16:46
Guffa16-May-09 16:46 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
devvvy16-May-09 17:04
devvvy16-May-09 17:04 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
Guffa22-May-09 13:27
Guffa22-May-09 13:27 
QuestionUse methods from another form Pin
michaelgr116-May-09 2:08
michaelgr116-May-09 2:08 
AnswerRe: Use methods from another form Pin
OriginalGriff16-May-09 2:39
mveOriginalGriff16-May-09 2:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.