Rediger

Del via


CodeMemberMethod.TypeParameters Property

Definition

Gets the type parameters for the current generic method.

public:
 property System::CodeDom::CodeTypeParameterCollection ^ TypeParameters { System::CodeDom::CodeTypeParameterCollection ^ get(); };
public System.CodeDom.CodeTypeParameterCollection TypeParameters { get; }
[System.Runtime.InteropServices.ComVisible(false)]
public System.CodeDom.CodeTypeParameterCollection TypeParameters { get; }
member this.TypeParameters : System.CodeDom.CodeTypeParameterCollection
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.TypeParameters : System.CodeDom.CodeTypeParameterCollection
Public ReadOnly Property TypeParameters As CodeTypeParameterCollection

Property Value

A CodeTypeParameterCollection that contains the type parameters for the generic method.

Attributes

Examples

The following code example shows the use of the TypeParameters property to add two type parameters to the CodeMemberMethod printMethod. This example is part of a larger example provided for the CodeTypeParameter class.

// Declare a generic method.
CodeMemberMethod printMethod = new CodeMemberMethod();
CodeTypeParameter sType = new CodeTypeParameter("S");
sType.HasConstructorConstraint = true;
CodeTypeParameter tType = new CodeTypeParameter("T");
sType.HasConstructorConstraint = true;

printMethod.Name = "Print";
printMethod.TypeParameters.Add(sType);
printMethod.TypeParameters.Add(tType);
' Declare a generic method.
Dim printMethod As New CodeMemberMethod()
Dim sType As New CodeTypeParameter("S")
sType.HasConstructorConstraint = True
Dim tType As New CodeTypeParameter("T")
tType.HasConstructorConstraint = True

printMethod.Name = "Print"
printMethod.TypeParameters.Add(sType)
printMethod.TypeParameters.Add(tType)

Remarks

A generic method contains one or more unspecified types known as type parameters. A type parameter name stands for the type within the body of the generic declaration.

Applies to

See also