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 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈