Click here to Skip to main content
15,902,189 members
Home / Discussions / C#
   

C#

 
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 
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 
devvvy wrote:
Just a thought, despite in IL code finalizer (or C#'s destructor) is virtual - does CLR automatically call BOTH (like in C++):
(a) ~Base
(b) ~Derived


Yes, the base class finalizer will be invoked at the end of the derived class finalizer.


devvvy wrote:

Also don't you think it's more clean and reliable if C# Disposable gets invoked the same way C++ virtual destructor does? That BOTH Base/Derived are invoked?


I agree, it is cleaner. To explain why it is not done right now,

interface ISome
{
   void DoSome();
}

class BaseSome : ISome
{
   public virtual void DoSome() { Console.WriteLine("BaseSome"); }
}

class DerivedSome : BaseSome
{
   public override void DoSome() { Console.WriteLine("DerivedSome"); }
}

void Main()
{
   ISome some = new DerivedSome();
   some.DoSome();
}


Would you expect DoSome to chain i.e. print "DerivedSome" and "BaseSome"? You wouldn't, because you've overrode the method to have custom behavior. Calling the base class method might be useful in some situations, but there's no way the language can force all overridden implementations to call the base implementation at the end/beginning.

Because disposal is exposed through IDisposable, an interface like ISome, what you expect cannot happen unless the C# compiler treats the interface as a special case.

The reason why it doesn't have to do this for finalizers is that the finalizer is declared in System.Object, which every .NET type must derive from.

Regards
Senthil [MVP - Visual C#]
_____________________________
My Home Page |My Blog | My Articles | My Flickr | WinMacro

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 
AnswerRe: Use methods from another form Pin
michaelgr116-May-09 3:03
michaelgr116-May-09 3:03 
GeneralRe: Use methods from another form Pin
OriginalGriff16-May-09 3:53
mveOriginalGriff16-May-09 3:53 
AnswerRe: Use methods from another form Pin
Manas Bhardwaj16-May-09 6:20
professionalManas Bhardwaj16-May-09 6:20 

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.