5
Answers

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

Rushal Arora

Rushal Arora

12y
3.9k
1
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)