I am new to C #. I have one confusion.
There are two classes A and B.
using System;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
A objA = new A();
A objB = new B();
}
}
class A
{
public void MethodA()
{
Console.WriteLine("method of A class");
}
}
class B : A
{
public void MethodB()
{
Console.WriteLine("method of B class");
}
}
}
Now the confusion that I have is that the meaning is:
A objB = new B();
I saw and instantiated a class such as thi:
A objB = new A();
Can someone tell me why we used:
A objB = new B();
Thanks in advance.
source
share