CodeTypeParameter Constructor (String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Initializes a new instance of the CodeTypeParameter class with the specified type parameter name.

Namespace:   System.CodeDom
Assembly:  System (in System.dll)

Public Sub New (
	name As String
)

Parameters

name
Type: System.String

The name of the type parameter.

The following code example shows the use of CodeTypeParameter constructor to add a type parameter. This example is part of a larger example provided for the CodeTypeParameter class.

Dim kType As New CodeTypeParameter("TKey")
kType.HasConstructorConstraint = True
kType.Constraints.Add(New CodeTypeReference(GetType(IComparable)))
kType.CustomAttributes.Add _
    (New CodeAttributeDeclaration("System.ComponentModel.DescriptionAttribute", _
        New CodeAttributeArgument(New CodePrimitiveExpression("KeyType"))))
Dim iComparableT As New CodeTypeReference("IComparable")
iComparableT.TypeArguments.Add(New CodeTypeReference(kType))

kType.Constraints.Add(iComparableT)

Dim vType As New CodeTypeParameter("TValue")
vType.Constraints.Add(New CodeTypeReference(GetType(IList(Of System.String))))
vType.CustomAttributes.Add _
    (New CodeAttributeDeclaration("System.ComponentModel.DescriptionAttribute", _
        New CodeAttributeArgument(New CodePrimitiveExpression("ValueType"))))

class1.TypeParameters.Add(kType)
class1.TypeParameters.Add(vType)

.NET Framework
Available since 2.0
Return to top
Show: