C# .NET - objects in c# - Asked By kiruba .e on 28-Mar-13 06:31 AM

Hi,

I have a doubt.

consider the below code:

class A
{
         public void add()
          {
            --
          }
}
Class B:A
{

    Public void subtract()
   {

   ----
   }

}
void main()
{

A obj1=new A();------------------------>1
obj1.add();
B obj2=new B();------------------------->2
obj2.subtract();
A obj3=new B();------------------------->3
B obj4=new A();
------------------------------>4

}

Can you explain these object initializing?..What does it mean...


Robbe Morris replied to kiruba .e on 28-Mar-13 08:34 AM
It means creating a new instance of object A or B.

The code you have here uses inheritance.  In this case, class B inherits the public characteristics of class A.