Re: Help with the, "this" initializer in a constructor.
From: Player (guess_at_My.email.address.scum.com)
Date: 11/01/04
- Next message: Stoitcho Goutsev \(100\) [C# MVP]: "Re: Should I Subclass TextBox ?"
- Previous message: perpolis: "Re: Erorr Handling in data grid??"
- In reply to: Nick Malik: "Re: Help with the, "this" initializer in a constructor."
- Next in thread: Player: "Re: Help with the, "this" initializer in a constructor."
- Reply: Player: "Re: Help with the, "this" initializer in a constructor."
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 1 Nov 2004 17:04:43 -0000
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Yeah great thanks Nick Malik..
I went through what you said, read some more then experimented a little..
I came out of it with the following code...
class A
{
public A()
{
myMethod();
}
public virtual void stuff()
{
Console.WrteLine("A");
}
} // end class A
class B : A
{
public B() : base()
{
}
public override void myMethod()
{
Console.WriteLine("B");
}
} // end class B
Which DOES end up giving me the desired output, "B".
And I now understand why it's done like that, and why the base constructor
is always called, explicitly or not; But how you can override such
constructors and/or methods in order to achieve the desired goal :)
In the case above, it's still calling the base constructor, which is calling
the, "myMethod()" method, it's just that I am explicitly calling the base
constructor in my derived class, AND overriding the, "myMethod" in the
derived class, to get the desired result.
Thanks again to all - appreciated :)
Player
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0
iQA/AwUBQYZsqS/z2sM4qf2WEQKBWgCfeUehgq3hJIMpe69DDwQDEguCPh8AnR/A
813v8OmJFUknYyR5uYp6EMxL
=7q0b
-----END PGP SIGNATURE-----
- Next message: Stoitcho Goutsev \(100\) [C# MVP]: "Re: Should I Subclass TextBox ?"
- Previous message: perpolis: "Re: Erorr Handling in data grid??"
- In reply to: Nick Malik: "Re: Help with the, "this" initializer in a constructor."
- Next in thread: Player: "Re: Help with the, "this" initializer in a constructor."
- Reply: Player: "Re: Help with the, "this" initializer in a constructor."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|