CodeMemberMethod.TypeParameters Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應