Solved

Overriding a method, how to know signature?

Posted on 2007-11-21
5
199 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
its working now.. a reboot sorted it out.. and thanks for the comments on the page_load info.

Assigning points
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now