How do I create a subclass in C# for ASP.NET using Visual Studio 2010?
Here is an example of writing a ParentClass and then creating a ChildClass as a sub class.
using System;
public class ParentClass
{
public ParentClass()
{
Console.WriteLine("Parent Constructor.");
}
public void print()
{
Console.WriteLine("I'm a Parent Class.");
}
}
public class ChildClass : ParentClass
{
public ChildClass()
{
Console.WriteLine("Child Constructor.");
}
public static void Main()
{
ChildClass child = new ChildClass();
child.print();
}
}
Output:
Parent Constructor. Child Constructor. I'm a Parent Class.
Rather than rewriting yet another example of .Net inheritance I have copied a decent example from the C Sharp Station website.