Sdílet prostřednictvím


CodeTypeParameter Konstruktory

Definice

Inicializuje novou instanci CodeTypeParameter třídy.

Přetížení

Name Description
CodeTypeParameter()

Inicializuje novou instanci CodeTypeParameter třídy.

CodeTypeParameter(String)

Inicializuje novou instanci CodeTypeParameter třídy se zadaným názvem parametru typu.

CodeTypeParameter()

Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs

Inicializuje novou instanci CodeTypeParameter třídy.

public:
 CodeTypeParameter();
public CodeTypeParameter();
Public Sub New ()

Poznámky

Pokud používáte tento konstruktor, měli byste nastavit Name vlastnost.

Platí pro

CodeTypeParameter(String)

Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs
Zdroj:
CodeTypeParameter.cs

Inicializuje novou instanci CodeTypeParameter třídy se zadaným názvem parametru typu.

public:
 CodeTypeParameter(System::String ^ name);
public CodeTypeParameter(string name);
new System.CodeDom.CodeTypeParameter : string -> System.CodeDom.CodeTypeParameter
Public Sub New (name As String)

Parametry

name
String

Název parametru typu.

Příklady

Následující příklad kódu ukazuje použití CodeTypeParameter konstruktoru k přidání parametru typu. Tento příklad je součástí většího příkladu poskytnutého CodeTypeParameter pro třídu.

CodeTypeParameter kType = new CodeTypeParameter("TKey");
kType.HasConstructorConstraint = true;
kType.Constraints.Add(new CodeTypeReference(typeof(IComparable)));
kType.CustomAttributes.Add(new CodeAttributeDeclaration(
    "System.ComponentModel.DescriptionAttribute",
        new CodeAttributeArgument(new CodePrimitiveExpression("KeyType"))));

CodeTypeReference iComparableT = new CodeTypeReference("IComparable");
iComparableT.TypeArguments.Add(new CodeTypeReference(kType));

kType.Constraints.Add(iComparableT);

CodeTypeParameter vType = new CodeTypeParameter("TValue");
vType.Constraints.Add(new CodeTypeReference(typeof(IList<System.String>)));
vType.CustomAttributes.Add(new CodeAttributeDeclaration(
    "System.ComponentModel.DescriptionAttribute",
        new CodeAttributeArgument(new CodePrimitiveExpression("ValueType"))));

class1.TypeParameters.Add(kType);
class1.TypeParameters.Add(vType);
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)

Platí pro