指定した型名の Type を返す式である、typeof 式を表します。
名前空間: System.CodeDom
アセンブリ: System (system.dll 内)
構文
'宣言
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeTypeOfExpression
Inherits CodeExpression
'使用
Dim instance As CodeTypeOfExpression
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
public class CodeTypeOfExpression : CodeExpression
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[ComVisibleAttribute(true)]
public ref class CodeTypeOfExpression : public CodeExpression
/** @attribute SerializableAttribute() */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
/** @attribute ComVisibleAttribute(true) */
public class CodeTypeOfExpression extends CodeExpression
SerializableAttribute
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)
ComVisibleAttribute(true)
public class CodeTypeOfExpression extends CodeExpression
解説
実行時に Type を返す typeof 式を表す、CodeTypeOfExpression。
Type プロパティは、Type オブジェクトを返すデータ型を指定します。
CodeTypeReferenceExpression を使用すると、CodeCastExpression を作成して名前を指定した型にオブジェクトをキャストするときのように、名前によって型を参照するソース コードを表すことができます。
使用例
CodeTypeOfExpression を使用して typeof 式を表す例を次に示します。
' 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)
' A Visual Basic code generator produces the following source code for the preceeding example code:
' GetType(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);
// A C# 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 = gcnew CodeTypeReference( "System.DateTime" );
// Creates a typeof expression for the specified type reference.
CodeTypeOfExpression^ typeof1 = gcnew CodeTypeOfExpression( typeRef1 );
// A C# 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);
// A VJ# code generator produces the following source code for the
// preceeding example code:
// System.DateTime.class.ToType();
継承階層
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeExpression
System.CodeDom.CodeTypeOfExpression
スレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
参照
関連項目
CodeTypeOfExpression メンバ
System.CodeDom 名前空間
CodeTypeReferenceExpression