다음을 통해 공유


CodeTypeReference 클래스

정의

형식에 대한 참조를 나타냅니다.

public ref class CodeTypeReference : System::CodeDom::CodeObject
public class CodeTypeReference : System.CodeDom.CodeObject
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeTypeReference : System.CodeDom.CodeObject
type CodeTypeReference = class
    inherit CodeObject
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeTypeReference = class
    inherit CodeObject
Public Class CodeTypeReference
Inherits CodeObject
상속
CodeTypeReference
특성

예제

다음 예제에서는 형식에 대한 참조를 CodeTypeReference 나타내는 데 사용하는 방법을 보여 줍니다.

// Creates a reference to the System.DateTime type.
CodeTypeReference typeRef1 = new CodeTypeReference("System.DateTime");

// Creates a typeof expression for the specified type reference.
CodeTypeOfExpression typeof1 = new CodeTypeOfExpression(typeRef1);

// Create a C# code provider
CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");

// Generate code and send the output to the console
provider.GenerateCodeFromExpression(typeof1, Console.Out, new CodeGeneratorOptions());
// The code generator produces the following source code for the preceeding example code:
//    typeof(System.DateTime)
' Creates a reference to the System.DateTime type.
Dim typeRef1 As New CodeTypeReference("System.DateTime")

' Creates a typeof expression for the specified type reference.
Dim typeof1 As New CodeTypeOfExpression(typeRef1)

' Create a Visual Basic code provider
Dim provider As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic")

' Generate code and send the output to the console
provider.GenerateCodeFromExpression(typeof1, Console.Out, new CodeGeneratorOptions())
' The code generator produces the following source code for the preceeding example code:
'    GetType(Date)

설명

CodeTypeReference 개체는 CodeDOM 개체의 형식을 나타내는 데 사용됩니다. CodeDOM 형식에 속성이 있는 Type 경우 형식입니다 CodeTypeReference. 예를 들어 CodeMemberField.Type 속성은 CodeTypeReference 필드의 데이터 형식을 나타내는 속성입니다.

개체 또는 문자열을 사용하여 A CodeTypeReferenceType 초기화할 수 있습니다. 항상 가능하지는 않지만 일반적으로 이 작업을 수행하는 것이 좋습니다 Type . 문자열을 사용하여 이 클래스의 인스턴스를 초기화하는 경우 모든 언어가 네임스페이스 가져오기를 지원하지 않으므로 항상 "콘솔" 대신 "System.Console"과 같은 정규화된 형식을 사용하는 것이 좋습니다. 배열에 대한 형식 개체를 전달하거나 순위를 매개 변수로 수락하는 생성자 중 하나를 사용하여 배열 형식을 지정할 수 있습니다.

이 속성은 BaseType 참조할 형식의 이름을 지정합니다. 배열 형식에 대한 참조의 경우 이 속성은 ArrayElementType 배열 요소의 형식을 나타내고 ArrayRank , 이 속성은 배열의 차원 수를 나타냅니다.

생성자

Name Description
CodeTypeReference()

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

CodeTypeReference(CodeTypeParameter)

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

CodeTypeReference(CodeTypeReference, Int32)

지정된 배열 형식 및 순위를 사용하여 클래스의 CodeTypeReference 새 인스턴스를 초기화합니다.

CodeTypeReference(String, CodeTypeReference[])

지정된 형식 이름 및 형식 인수를 CodeTypeReference 사용하여 클래스의 새 인스턴스를 초기화합니다.

CodeTypeReference(String, CodeTypeReferenceOptions)

지정된 형식 이름 및 코드 형식 참조 옵션을 사용하여 클래스의 CodeTypeReference 새 인스턴스를 초기화합니다.

CodeTypeReference(String, Int32)

지정된 배열 형식 이름 및 순위를 사용하여 클래스의 CodeTypeReference 새 인스턴스를 초기화합니다.

CodeTypeReference(String)

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

CodeTypeReference(Type, CodeTypeReferenceOptions)

지정된 형식 및 코드 형식 참조를 CodeTypeReference 사용하여 클래스의 새 인스턴스를 초기화합니다.

CodeTypeReference(Type)

지정된 형식을 사용하여 클래스의 CodeTypeReference 새 인스턴스를 초기화합니다.

속성

Name Description
ArrayElementType

배열에 있는 요소의 형식을 가져오거나 설정합니다.

ArrayRank

배열의 배열 순위를 가져오거나 설정합니다.

BaseType

참조되는 형식의 이름을 가져오거나 설정합니다.

Options

코드 형식 참조 옵션을 가져오거나 설정합니다.

TypeArguments

현재 제네릭 형식 참조의 형식 인수를 가져옵니다.

UserData

현재 개체에 대한 사용자 정의 데이터를 가져옵니다.

(다음에서 상속됨 CodeObject)

메서드

Name Description
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상