Some basic questions

P

p988

What is the purpose of Trace.AutoFlush in a window form app?

In a window form app, why needed calling "InitializaComponent()"? What're
accomplished by such call?


Other questions are related to the code below:

protected override void Dispose(bool disposing)
{
...
base.Dispose(disposing);
}

Why "protected" keyword used above? Is it because the member for base class
uses "protected"?

Why "override" used above? What if it's missing? How to hide the virtual
method, Dispose(), in base class?

Why need to call base.Dispose() above?

Thank you in advance!
 
F

Frank Oquendo

p988 said:
What is the purpose of Trace.AutoFlush in a window form app?

To force a flush after write. Otherwise, nothing is written to your
TextTraceListeners until you call Trace.Flush();
In a window form app, why needed calling "InitializaComponent()"?
What're accomplished by such call?

It establishes the environment by instantiating your controls and
setting their properties.
protected override void Dispose(bool disposing)
{
...
base.Dispose(disposing);
}

Why "protected" keyword used above? Is it because the member for
base class uses "protected"?

Yes but there's more to it. "protected" reserves the method for internal
use by the object, not it's clients.
Why "override" used above? What if it's missing?

The override keyword signifies that you're supplying a new
implementation for an existing method. As for it being missing, no
problem. Calls to this method will result in the invocation of the
implementation found in the base class.
How to hide the virtual method, Dispose(), in base class?

Not a good idea. Why would you want to do that?
Why need to call base.Dispose() above?

This allows for any additional procesing necessary to dispose of managed
objects in use by your class. Typically an override augments the base
implementation rather than replacing it. This allows you to concentrate
on just the bit of behavior you wish to customize.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top