Rushal Arora

Rushal Arora

  • NA
  • 112
  • 175.9k

How type casting is done between base class and derived class?

Oct 22 2012 1:25 PM
Hi Everyone,

Please let me know the solution of below question :

Q.1) How type casting is done between base class and derived class?

button_click(object sender, EventArrgs e)
Button b = (button) sender;// button class is derived from object class, for this typecasting to happen button reference must be there in object class but object class is created by microsoft so we can't see . So my question is how reference of button class is written in object class?

class Object
{
Button b;
}

class Button : Object
{}

Now can we write :
Button b = new Object();
  and
Object o = new Button();





 Thanks and Regards





Answers (5)