Inheritance (C # Programming Guide)
Classes can inherit from other classes. This is done by placing a colon after the class name when declaring the class, and then specifying the class (that is, the base class) to inherit from after the colon. For example:
public class A
{
public A() { }
}
public class B : A
{
public B() { }
}
The new class (that is, the derived class) gets all the non-public data and behavior of the base class and all other data or behavior that the new class defines for itself. Therefore, the new class has two valid types: The type of the new class and the type of the class it inherits.
In the example above, Class B is both a valid B and a valid A. When you access a B object, you can use a cast operation to convert it to a object. Casting does not change the B object, but your view of B objects will be limited to the data and behavior of a. After casting B to a, you can cast it back to B. Not all instances of a are cast to B, and only those instances that are actually instances of B can be cast to B. If Class B is accessed as type B, the data and behavior of both class A and Class B can be obtained at the same time. The ability of an object to represent multiple types is called polymorphism. For more information, refer to this article polymorphism.