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

Subtype and enclosing type

What is Subtype and enclosing type? What are their example?
0
william007
Asked:
william007
1 Solution
 
icrCommented:
http://en.wikipedia.org/wiki/Subtype
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.

http://msdn2.microsoft.com/en-us/library/tdz1bea9(VS.71).aspx
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.
0
 
william007Author Commented:
Thanks:)
0

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