CodeTypeParameter 생성자

정의

CodeTypeParameter 클래스의 새 인스턴스를 초기화합니다.

오버로드

CodeTypeParameter()

CodeTypeParameter 클래스의 새 인스턴스를 초기화합니다.

CodeTypeParameter(String)

지정된 형식 매개 변수 이름을 사용하여 CodeTypeParameter 클래스의 새 인스턴스를 초기화합니다.

CodeTypeParameter()

Source:
CodeTypeParameter.cs
Source:
CodeTypeParameter.cs
Source:
CodeTypeParameter.cs

CodeTypeParameter 클래스의 새 인스턴스를 초기화합니다.

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

설명

이 생성자를 사용하는 경우 속성을 설정 Name 해야 합니다.

적용 대상

CodeTypeParameter(String)

Source:
CodeTypeParameter.cs
Source:
CodeTypeParameter.cs
Source:
CodeTypeParameter.cs

지정된 형식 매개 변수 이름을 사용하여 CodeTypeParameter 클래스의 새 인스턴스를 초기화합니다.

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

매개 변수

name
String

형식 매개 변수의 이름입니다.

예제

다음 코드 예제에서는 형식 매개 변수를 추가 하는 생성자를 사용 하 여 CodeTypeParameter 보여줍니다. 이 예제는에 대해 제공 된 큰 예제의 일부는 CodeTypeParameter 클래스입니다.

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)

적용 대상