Can a base class contain its derived class?
Yes. But the reverse is not possible.
using System;
using System.Collections.Generic;
using System.Text;
namespace OppsTest
{
class A
{
int i = 1;
public A()
{
}
public void testa()
{
Console.Out.Write(i);
}
}
class B : A
{
int j = 3;
public B()
{
}
public void testb()
{
Console.Out.Write(j);
}
}
class Program
{
static void Main(string[] args)
{
A a = new B();
a.testa();
Console.In.Read();
}
}
}
Subscribe to:
Post Comments (Atom)
0 comments
Post a Comment