You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following example defines a generic class with two type parameters and then defines a second generic class that derives from the first class. The derived class's base class has two type arguments: the first is <xref:System.Int32> and the second is a type parameter of the derived type. The example displays information about these generic classes, including the positions reported by the <xref:System.Type.GenericParameterPosition%2A> property.
The following code example defines a class that has a generic method, assigns a type argument to the method, and invokes the resulting constructed generic method. It also displays information about the generic method definition and the constructed method. When displaying information about the type parameters of the generic method definition, in the `DisplayGenericMethodInfo` method, the example code shows the value of the <xref:System.Type.DeclaringMethod%2A> property for the method's generic type parameter.
@@ -1557,32 +1557,32 @@ The `filter` argument can be a custom delegate of type <xref:System.Reflection.M
1557
1557
For example, the fully qualified name of the <xref:System.String> type is `System.String`. Contrast this with the assembly-qualified name returned by the <xref:System.Type.AssemblyQualifiedName%2A> property, which consists of the full name plus the full assembly name.
1558
1558
1559
1559
If the current type represents a closed generic type, the type arguments in the string returned by the <xref:System.Type.FullName%2A> property are qualified by their full assembly name, even though the string representation of the generic type itself is not qualified by its full assembly name. The following example illustrates the difference in the FullName property for a type that represents generic type definition and one that represents a closed generic type.
- The current <xref:System.Type> object represents a type parameter of a generic type.
1567
1567
1568
1568
The following example retrieves the type parameter of the <xref:System.Nullable%601> type and attempts to display its <xref:System.Type.FullName%2A> property.
- The current <xref:System.Type> object represents an array type, a pointer type, or a `byref` type that is based on a generic type parameter.
1574
1574
1575
1575
The following example defines a generic type, `Generictype1<T>`, with three methods: `Display(T[])`, which is passed an array of type T; `HandleT(T)`, which is passed a T object; and `ChangeValue(ref T)`, which is passed a T object by reference. Because C# and Visual Basic do not allow us to define T as a pointer in the `HandleT` method, we have to call the <xref:System.Type.MakePointerType%2A> method on the <xref:System.Type> object that represents the method's parameter type to create a pointer to a generic type. The output from the example shows that in all three cases, the <xref:System.Type.FullName%2A> property is `null`.
- The current type contains generic type parameters that have not been replaced by specific types (that is, the <xref:System.Type.ContainsGenericParameters%2A> property returns `true`), but the type is not a generic type definition (that is, the <xref:System.Type.IsGenericTypeDefinition%2A> property returns `false`
1581
1581
1582
1582
In the following example, `Derived<T>` inherits from `Base<T>`. The <xref:System.Type.BaseType%2A> property obtains the <xref:System.Type> object that represents the base type of `Derived<T>`, and its <xref:System.Type.FullName%2A> property returns `null`.
To get a <xref:System.Type.FullName%2A> that is not `null`, you can use the <xref:System.Type.GetGenericTypeDefinition%2A> method to get the generic type definition, as the example illustrates.
1588
1588
@@ -1592,15 +1592,15 @@ The `filter` argument can be a custom delegate of type <xref:System.Reflection.M
1592
1592
1593
1593
## Examples
1594
1594
The following example displays the full name of the specified type.
The following example compares the strings returned by the <xref:System.Type.ToString%2A> method and the <xref:System.Type.Name%2A>, `FullName`, and <xref:System.Type.AssemblyQualifiedName%2A> properties.
0 commit comments