Re: Overriding newbie question.
From: Richard Blewett [DevelopMentor] (richardb_at_NOSPAMdevelop.com)
Date: 12/05/04
- Next message: Simon: "Re: Managing Nulls in the DB"
- Previous message: Joachim Pense: "Re: Built in function for text cut-off?"
- In reply to: CobraStrikes_at_al.com: "Overriding newbie question."
- Messages sorted by: [ date ] [ thread ]
To: microsoft.public.dotnet.languages.csharp Date: Sun, 05 Dec 2004 03:41:04 -0800
The base and derived class method signatures for method B must match exactly so:
class Foo
{
public virtual int MyMethod(double d)
{
}
}
class Bar : Foo
{
public override int MyMethod(double d)
{
// this one will not always get called
}
}
The other fundemental thing is this will only work if the method is being called on a derived class object. So for the above example:
Foo f = new Foo();
f.MyMethod(2.0); // this will call Foo.MyMethod
f = new Bar();
f.MyMethod(2.0); // this will call Bar.MyMethod
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Hi,
A control has
privtae void MethodA()
{
//etc
MethodB();
{
// NO CODE, THE PROGRAM WHICH WILL INHERIT THIS CONTROL WILL PROVIDE THE CODE.
}
I hope this make sense, I have tried using virtual and override without success the control always calls its own methodB
any help/thoughts will be appericated.
- Next message: Simon: "Re: Managing Nulls in the DB"
- Previous message: Joachim Pense: "Re: Built in function for text cut-off?"
- In reply to: CobraStrikes_at_al.com: "Overriding newbie question."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|