Export (0) Print
Expand All

CodeTypeParameter Constructor (String)

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

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

'Declaration
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

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft