Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Jun 14, 2012, 5:38 PM EDT
Please refer the below links
http://www.functionx.com/aspnet/classes/inheritance.htm
http://www.programcall.com/19/csnet/inheritance-with-an-example-in-csnet.aspx
http://aspnet.4guysfromrolla.com/articles/041305-1.aspx
http://www.exforsys.com/tutorials/csharp/inheritance-in-csharp.html
http://www.codeproject.com/Articles/1445/Introduction-to-inheritance-polymorphism-in-C
http://www.techrepublic.com/article/establish-common-aspnet-page-features-through-inheritance/5772080
Thanks
Amit PatelRank #622 · 3.8K reputationPosted Jun 14, 2012, 7:17 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Jun 14, 2012, 7:34 PM EDT
Creating a new class from existing class is called as inheritance.When you derive a class from a base class, the derived class will inherit all members of the base class except constructors, though whether the derived class would be able to access those members would depend upon the accessibility of those members in the base class.
Main advantage of inheritance is reusability of the code.
public class Animal
{
public Animal()
{
Console.WriteLine("Animal constructor");
}
public void Greet()
{
Console.WriteLine("Animal says Hello");
}
public void Talk()
{
Console.WriteLine("Animal talk");
}
public virtual void Sing()
{
Console.WriteLine("Animal song");
}
}
public class Cow : Animal
{
public Cow()
{
Console.WriteLine("Cow constructor");
}
public new void Talk()
{
Console.WriteLine("Dog talk");
}
public override void Sing()
{
Console.WriteLine("Cow song");
}
}
Animal cow = new Cow();
cow.Talk();
cow.Sing();
cow.Greet();
//Output
Animal constructor
cow constructor
Animal talk
cow song
Animal says Hello
please refer
http://www.programcall.com/19/csnet/inheritance-with-an-example-in-csnet.aspx
hope this will help you.