|
-
Mako Shark
rg, i give up, C# question, diff between new and override w/ overriding methods?
In looking over examples ive noticed that there seem to be two different ways to have a method with the same name in the child class and parent class. Ya ya, over riding the parent method, but two ways? and they seem to act different as well. Due to the fact that "new" is used when ever an object is created actually finding any info out on this has been pretty hard.
just so we're all on the same page, here are the two methods
protected override void OnPaint(PaintEventArgs pea) {...}
protected new void OnPaint(PaintEventArgs pea) {...}
From testing ive noticed that when i use "new" and execute the method in the child class code from the parent class is executed, and when i use "override" and execute the method in the chile class code from the child class is used.
So using the "override" keyword does what i would expect, it overrides the method.
What then, does the "new" keyword do in this case?
Last edited by Mancora; 06-26-2005 at 04:45 PM.
-
Mako Shark
Last edited by Mancora; 06-26-2005 at 06:56 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|