Generic: open constructed type vs. instance type
On the one hand:
Given the generic class declaration
class List<T> {...}
some examples of constructed types are List<T>, List<int> and List<List<string>>.
A constructed type that uses one or more type parameters, such asList<T>, is called anopen constructed type
And on the other hand:
The following shows several class declarations
along with their instance types:
class List<T> {...} //instance type:List<T>
My conclusion:open_constructed_type ==instance_type. Is it true?
[765 byte] By [
Smarty] at [2008-2-22]
Not exactly. An open constructed type is a type with open Type parameters, for example:
class List<T>
{
}
class MyClass<T, B>
{
}
however, this is not a open constructed type:
class MyList : List<int>
{
}
The instance type is just how the class is referred within the class itself, for example:
class List<T>
{
public void Foo()
{
List<T>.DoSomething(); // List<T> is the instance type
}
public static void DoSomething()
{
}
}
class List
{
public void Foo()
{
List.DoSomething(); // List is the instance type
}
public static void DoSomething()
{
}
}
Thanks for explanation! So, instance type is some... substance, that we can(and will) use within type declaration ONLY, right?