|
-
Nov 10th, 2002, 07:02 AM
#1
Thread Starter
Lively Member
inherited classes
Hi,
Here is another one 
Take this case:
I've these classes:
class A{ public void M{} }
class B : A {public override void M{} }
class C: B {}
I need, from class C, to call the base class method B.M() rather that A.M()...
Is it possble to do this distinguish?
Bye, thanx
-
Nov 10th, 2002, 11:42 AM
#2
Frenzied Member
Code:
using System;
using System.Windows.Forms;
namespace Test
{
public class A
{
public virtual void M()
{
MessageBox.Show("Method M From Class A");
}
}
public class B : A
{
public override void M()
{
MessageBox.Show("Method M From Class B");
}
}
public class C : B
{
}
}
Hope that helped
Dont gain the world and lose your soul
-
Nov 10th, 2002, 11:49 AM
#3
Thread Starter
Lively Member
Hope that helped
Well, thanx, but I meant: can I call
Code:
C.M() // call the M Method from base class A
C.M() // call the M Method from base class B
-
Nov 12th, 2002, 04:19 PM
#4
Hyperactive Member
Nope.
B's implementation of the M method covers A's implementation as far as the user of object C is concerned.
-scott
he he he
-
Nov 12th, 2002, 04:36 PM
#5
Thread Starter
Lively Member
Nope.
B's implementation of the M method covers A's implementation as far as the user of object C is concerned.
So, wen I call I always call the first ancestor method?
Cya!
-
Nov 12th, 2002, 11:30 PM
#6
Frenzied Member
I think that just calls the method from the last class you inherited from.
Dont gain the world and lose your soul
-
Nov 12th, 2002, 11:44 PM
#7
PowerPoster
Yep, you will call the M() method of the immediate parent you derived from.
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
|
Click Here to Expand Forum to Full Width
|