This tutorial will explain inheritance and virtual methods and how to use them in C#(im assuming you have a basic knowledge of oop concepts). Inhertance is when a class uses another class has a base and aquires all its variables and methods, take this class for example:
this next class uses that one a base( it inherits from it)
[IMG]http://i37.[censored].com/fxax5u.png[/IMG]
As you can see the class Herp contains the method and varible from its base class as well has the other method we added to it.
Virtual methods are a way of changing the behavior of inherited methods:
As you can see the inherited class is overriding the virtual method DoWork, the line 'base.DoWork();' calls the original DoWork method from the base class so the output of DoWork from the class Herp would be:
Doing inherited class work
Doing base class work
please leave a comment if you liked this tutorial or if you have any problems or questions about it
Code
class Derp
{
public int var;
public void Write(string text)
{
Console.Write(text);
}
}Code
class Herp : Derp
{
public void WriteLine(string text)
{
Write(text + "\n");
}
}As you can see the class Herp contains the method and varible from its base class as well has the other method we added to it.
Virtual methods are a way of changing the behavior of inherited methods:
Code
class Derp
{
public virtual void DoWork()
{
Console.WriteLine("Doing base class work");
}
}Code
class Herp : Derp
{
public override void DoWork()
{
Console.WriteLine("Doing inherited class work");
base.DoWork();
}
}Doing inherited class work
Doing base class work
please leave a comment if you liked this tutorial or if you have any problems or questions about it

