Solved

Overriding a method, how to know signature?

Posted on 2007-11-21
5
201 Views
Last Modified: 2010-04-15
hi there,

i wonder if anyone can help, i am overriding a couple of methods from a class... but is there anyway to easily create the method without having to look at the object browser to know the signature..

intellisense doesn't seem to provide me with the signature of the method i am ovverriding so i don't know which parameters to include?

Any ideas?

Thanks
0
Comment
Question by:iangregson1
  • 3
  • 2
5 Comments
 
LVL 25

Accepted Solution

by:
imitchie earned 500 total points
ID: 20332322
intellisense: try using base.MethodName(  at this point, it should give you the signature?
I think in the code window, there should also be an option to "generate override methods" for base class
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20332337
if you are inheriting from an abstract class, you can type a skeleton like so

public class MyTest : AbstractClass {}

then hover over the A in "AbstractClass".
choose: implement abstract class "AbstractClass"

if it's inheriting a concrete class, then you create the class first.  When you start  typing the method signature "   public override void M" below, code completion should give you the ones you can override starting with M

public class My2Test : MyTest {
   public override void M
}
0
 

Author Comment

by:iangregson1
ID: 20332387
Damb! yes thats what i thought, it wasn't working i think i need to reboot...

I wonder if i can ask 1 more thing... it is working but i just want to see if i am doing it the best way..

I have a class (not abstract but base) which another class inherits

There is some code in the base class in page_load that MUST be run no matter what

and then the derived class can implement/ovveride its own page_load

question is .... what is the program forgets to call base.Page_Load etc..

Is there some other way... maybe sealing a method on onload or something??

should i really be making virtual page_load rather than onLoad..

Any advice really appreciated

Thanks
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20332405
you can
mark the page_load as final - so that this cannot be overridden
in page_load, do what you must do, then make a call to another function, say "on_page_load" which you make virtual

now descendant classes can interact with page load (override "on_page_load"), but still not escape the "must happen" code
0
 

Author Comment

by:iangregson1
ID: 20332503
its working now.. a reboot sorted it out.. and thanks for the comments on the page_load info.

Assigning points
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Code works but it's slow 28 70
Finally almost got it 5 36
What namespace do I need to import? 2 25
Printing 1 51
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question