Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Overriding a method, how to know signature?

Posted on 2007-11-21
5
202 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

840 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