Hi all,
I am expecting the output to be
"I am from sub"
"I am from base"
but its not coming.... where am i making mistake?
I know I could achieve this by calling base.PrintOne in subclass... but i dont want it that way.
I want it to be called from base itself.
Please comment.
Thanks in advance.
Zacksoniar
Code:
namespace ConsoleApplication1
{
class I
{
public void PrintIt()
{
PrintOne();
((I)this).PrintOne();
}
public virtual void PrintOne()
{
Console.WriteLine("I am from base.\n");
}
}
class G:I
{
public override void PrintOne()
{
Console.WriteLine("I am from sub.\n");
}
}
class Program
{
static void Main(string[] args)
{
G g = new G();
g.PrintIt();
Console.ReadLine();
}
}
}
"I am from sub"
"I am from base"
but its not coming.... where am i making mistake?
I know I could achieve this by calling base.PrintOne in subclass... but i dont want it that way.
I want it to be called from base itself.
Please comment.
Thanks in advance.
Zacksoniar
Comment