content copied .....
The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class. A derived class can have only one direct base class. However, inheritance is transitive. If ClassC is derived from ClassB, and ClassB is derived from ClassA, ClassC inherits the members declared in ClassB and ClassA.
When you derive a class from a base class, the derived class will inherit all members of the base class except constructors. The Derived class re-use the code of base class based on accessibility level of those member.
Example Of Base Class :
public class Clsbase : System.Web.UI.Page
{
protected override void OnLoad(EventArgs e)
{
Response.Write("From base class");
base.OnLoad(e);
}
}
Example Of Derived Class :
public partial class ClsDerived : Clsbase
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("From Derived Class");
}
}
The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class. A derived class can have only one direct base class. However, inheritance is transitive. If ClassC is derived from ClassB, and ClassB is derived from ClassA, ClassC inherits the members declared in ClassB and ClassA.
When you derive a class from a base class, the derived class will inherit all members of the base class except constructors. The Derived class re-use the code of base class based on accessibility level of those member.
Example Of Base Class :
public class Clsbase : System.Web.UI.Page
{
protected override void OnLoad(EventArgs e)
{
Response.Write("From base class");
base.OnLoad(e);
}
}
Example Of Derived Class :
public partial class ClsDerived : Clsbase
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("From Derived Class");
}
}
No comments:
Post a Comment