CodeMemberMethod.TypeParameters Property

 

Gets the type parameters for the current generic method.

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

[ComVisibleAttribute(false)]
public CodeTypeParameterCollection TypeParameters { get; }

Property Value

Type: System.CodeDom.CodeTypeParameterCollection

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

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.

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);

.NET Framework
Available since 2.0
Return to top
Show: