• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 786
  • Last Modified:

Subtype and enclosing type

What is Subtype and enclosing type? What are their example?
1 Solution
A general type "Bird" can be subclassed into multiple subtypes (inheritance). They share all the information with Bird, but can define their own as well. Here is another example, with some code:
public class Person
    public string Name;

public class Employee: Person
    public int Salary;

Because Employee is a subclass (because C# uses classes they tend to be called subclasses instead of subtype) of Person it inherits the Name field, but also adds it's own Salary field.

To define an enclosing type we must first look at nested types. A nested type is when a type is defined inside another type:
public class TextBox
    public class Scrollbars
Which you can then reference by using TextBox.Scrollbars. However, unlike namespaces TextBox can also have it's own information and you can create instances of both TextBox and TextBox.Scrollbars.
In this instance TextBox would be Scrollbars enclosing type.
william007Author Commented:

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now