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 = gcnew CodeTypeReference("System.DateTime");

// Creates a typeof expression for the specified type reference.
CodeTypeOfExpression^ typeof1 = gcnew 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, gcnew 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.
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 フィールドのデータ型を表す です。

CodeTypeReference 、オブジェクトまたは文字列で Type 初期化できます。 通常は、 を使用 Type してこれを行うことをお勧めしますが、常に可能であるとは限りません。 文字列を使用してこのクラスのインスタンスを初期化する場合は、すべての言語で名前空間のインポートがサポートされているわけではないため、常に "コンソール" ではなく "System.Console" などの完全修飾型を使用することを強くお勧めします。 配列型は、配列の型オブジェクトを渡すか、ランクをパラメーターとして受け取るコンストラクターのいずれかを使用して指定できます。

プロパティは BaseType 、参照する型の名前を指定します。 配列型への参照の場合、 プロパティは ArrayElementType 配列の要素の型を示し、 プロパティは ArrayRank 配列内の次元の数を示します。

コンストラクター

CodeTypeReference()

CodeTypeReference クラスの新しいインスタンスを初期化します。

CodeTypeReference(CodeTypeParameter)

コード型パラメーターを指定して、CodeTypeReference クラスの新しいインスタンスを初期化します。

CodeTypeReference(CodeTypeReference, Int32)

配列の型とランクを指定して、CodeTypeReference クラスの新しいインスタンスを初期化します。

CodeTypeReference(String)

型名を指定して、CodeTypeReference クラスの新しいインスタンスを初期化します。

CodeTypeReference(String, CodeTypeReference[])

型名と型引数を指定して、CodeTypeReference クラスの新しいインスタンスを初期化します。

CodeTypeReference(String, CodeTypeReferenceOptions)

型名とコード型参照オプションを指定して、CodeTypeReference クラスの新しいインスタンスを初期化します。

CodeTypeReference(String, Int32)

配列の型名とランクを指定して、CodeTypeReference クラスの新しいインスタンスを初期化します。

CodeTypeReference(Type)

指定された型を使用して、CodeTypeReference クラスの新しいインスタンスを初期化します。

CodeTypeReference(Type, CodeTypeReferenceOptions)

型とコード型参照を指定して、CodeTypeReference クラスの新しいインスタンスを初期化します。

プロパティ

ArrayElementType

配列内の要素の型を取得または設定します。

ArrayRank

配列の配列ランクを取得または設定します。

BaseType

参照される型の名前を取得または設定します。

Options

コード型参照オプションを取得または設定します。

TypeArguments

現在のジェネリック型参照の型引数を取得します。

UserData

現在のオブジェクトのユーザー定義可能なデータを取得します。

(継承元 CodeObject)

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象