CodeTypeDeclarationとは? わかりやすく解説

CodeTypeDeclaration イベント


パブリック イベントパブリック イベント

  名前 説明
パブリック イベント PopulateBaseTypes BaseTypes コレクションが最初にアクセスされたときに発生します。
パブリック イベント PopulateMembers Members コレクションが最初にアクセスされたときに発生します。
参照参照

関連項目

CodeTypeDeclaration クラス
System.CodeDom 名前空間
CodeTypeDeclarationCollection
GeneratorSupport

CodeTypeDeclaration クラス

クラス、構造体、インターフェイス、または列挙体の型宣言を表します。

名前空間: System.CodeDom
アセンブリ: System (system.dll 内)
構文構文

<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeTypeDeclaration
    Inherits CodeTypeMember
Dim instance As CodeTypeDeclaration
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class CodeTypeDeclaration : CodeTypeMember
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class CodeTypeDeclaration : public
 CodeTypeMember
/** @attribute SerializableAttribute() */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class CodeTypeDeclaration extends CodeTypeMember
SerializableAttribute 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class CodeTypeDeclaration extends
 CodeTypeMember
解説解説

CodeTypeDeclaration を使用して、クラス、構造体、インターフェイス、または列挙体を宣言するコードを表すことができます。CodeTypeDeclaration を使用して、別の型の中に入れ子になった型を宣言できます。

BaseTypes プロパティは、宣言される型の 1 つ以上の基本型を指定します。Members プロパティは、型のメンバを格納します。これには、メソッド、フィールド、プロパティ、コメント、および他の型があります。TypeAttributes プロパティは、型宣言の TypeAttributes 値を示します。これはその型のカテゴリを示します。IsClass、IsStruct、IsEnum、および IsInterface の各メソッドは、それぞれ、その型がクラス型、構造体型、列挙体型、またはインターフェイス型かどうかを示します。

メモメモ

プログラミング言語によっては、参照型またはクラスの宣言しかサポートされないこともあります。言語固有の CodeDOM コード ジェネレータがインターフェイス、列挙体、または値型の宣言をサポートしているかどうかを調べるには、Supports メソッドを呼び出して該当する GeneratorSupport フラグを調べます。DeclareInterfaces はインターフェイスのサポートを示し、DeclareEnums は列挙体のサポートを示し、DeclareValueTypes は構造体などの値型のサポートを示します。

1 つの宣言内に完結するクラスまたは構造体の実装を作成することも、複数の宣言にわたって実装することもできます。IsPartial プロパティは、型宣言が完全か、部分的かを示します。部分的な型宣言がサポートされないコード ジェネレータもあるので、PartialTypes フラグを指定して Supports メソッドを呼び出し、このサポートをテストします。

使用例使用例

CodeTypeDeclaration を使用して型を宣言する例を次に示します。

' Creates a new type declaration.
Dim newType As New CodeTypeDeclaration("TestType")
   ' name parameter indicates the name of the type.
   ' Sets the member attributes for the type to private.
   newType.Attributes = MemberAttributes.Private
   ' Sets a base class which the type inherits from.
   newType.BaseTypes.Add("BaseType")

' A Visual Basic code generator produces the following source code for
 the preceeding example code:

' Class TestType
'    Inherits BaseType
' End Class
// Creates a new type declaration.
CodeTypeDeclaration newType = new CodeTypeDeclaration(
    // name parameter indicates the name of the type.
    "TestType");
// Sets the member attributes for the type to private.
newType.Attributes = MemberAttributes.Private;
// Sets a base class which the type inherits from.
newType.BaseTypes.Add( "BaseType" );            

// A C# code generator produces the following source code for the preceeding
 example code:

// class TestType : BaseType
// {
// }
// Creates a new type declaration.

// name parameter indicates the name of the type.
CodeTypeDeclaration^ newType = gcnew CodeTypeDeclaration( "TestType" );

// Sets the member attributes for the type to private.
newType->Attributes = MemberAttributes::Private;

// Sets a base class which the type inherits from.
newType->BaseTypes->Add( "BaseType" );

// A C# code generator produces the following source code for the preceeding
 example code:
// class TestType : BaseType
// {
// }
// Creates a new type declaration.
CodeTypeDeclaration newType = new CodeTypeDeclaration(
    // name parameter indicates the name of the type.
    "TestType");

// Sets the member attributes for the type to private.
newType.set_Attributes(MemberAttributes.Private);

// Sets a base class which the type inherits from.
newType.get_BaseTypes().Add("BaseType");
// A VJ# code generator produces the following source code for the
// preceeding example code:
// class TestType extends BaseType
// {
// }
継承階層継承階層
System.Object
   System.CodeDom.CodeObject
     System.CodeDom.CodeTypeMember
      System.CodeDom.CodeTypeDeclaration
         System.CodeDom.CodeTypeDelegate
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CodeTypeDeclaration メンバ
System.CodeDom 名前空間
CodeTypeDeclarationCollection
GeneratorSupport

CodeTypeDeclaration コンストラクタ ()


CodeTypeDeclaration コンストラクタ

CodeTypeDeclaration クラスの新しいインスタンスを初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
CodeTypeDeclaration () CodeTypeDeclaration クラスの新しいインスタンスを初期化します。
CodeTypeDeclaration (String) 指定した名前を使用して、CodeTypeDeclaration クラスの新しいインスタンスを初期化します。
参照参照

関連項目

CodeTypeDeclaration クラス
CodeTypeDeclaration メンバ
System.CodeDom 名前空間

CodeTypeDeclaration コンストラクタ (String)


CodeTypeDeclaration プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Attributes  メンバの属性を取得または設定します。 ( CodeTypeMember から継承されます。)
パブリック プロパティ BaseTypes 型の基本型を取得します。
パブリック プロパティ Comments  型メンバのコメント コレクションを取得します。 ( CodeTypeMember から継承されます。)
パブリック プロパティ CustomAttributes  メンバのカスタム属性を取得または設定します。 ( CodeTypeMember から継承されます。)
パブリック プロパティ EndDirectives  メンバの終了ディレクティブを取得します。 ( CodeTypeMember から継承されます。)
パブリック プロパティ IsClass 型がクラスまたは参照型かどうかを示す値を取得または設定します。
パブリック プロパティ IsEnum 型が列挙体かどうかを示す値を取得または設定します。
パブリック プロパティ IsInterface 型がインターフェイスかどうかを示す値を取得または設定します。
パブリック プロパティ IsPartial 型宣言が完全か部分的かを示す値を取得または設定します。
パブリック プロパティ IsStruct 型が値型 (構造体) かどうかを示す値を取得または設定します。
パブリック プロパティ LinePragma  型メンバのステートメントが発生する行を取得または設定します。 ( CodeTypeMember から継承されます。)
パブリック プロパティ Members 表される型のクラス メンバのコレクションを取得します。
パブリック プロパティ Name  メンバの名前を取得または設定します。 ( CodeTypeMember から継承されます。)
パブリック プロパティ StartDirectives  メンバの開始ディレクティブを取得します。 ( CodeTypeMember から継承されます。)
パブリック プロパティ TypeAttributes 型の属性を取得または設定します。
パブリック プロパティ TypeParameters 型宣言の型パラメータを取得します。
パブリック プロパティ UserData  現在のオブジェクトのユーザー定義可能なデータを取得または設定します。 ( CodeObject から継承されます。)
参照参照

関連項目

CodeTypeDeclaration クラス
System.CodeDom 名前空間
CodeTypeDeclarationCollection
GeneratorSupport

CodeTypeDeclaration メソッド


CodeTypeDeclaration メンバ

クラス、構造体、インターフェイス、または列挙体の型宣言を表します。

CodeTypeDeclaration データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド CodeTypeDeclaration オーバーロードされます。 CodeTypeDeclaration クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Attributes  メンバの属性を取得または設定します。(CodeTypeMember から継承されます。)
パブリック プロパティ BaseTypes 型の基本型を取得します。
パブリック プロパティ Comments  型メンバのコメント コレクションを取得します。(CodeTypeMember から継承されます。)
パブリック プロパティ CustomAttributes  メンバのカスタム属性を取得または設定します。(CodeTypeMember から継承されます。)
パブリック プロパティ EndDirectives  メンバの終了ディレクティブを取得します。(CodeTypeMember から継承されます。)
パブリック プロパティ IsClass 型がクラスまたは参照型かどうかを示す値を取得または設定します。
パブリック プロパティ IsEnum 型が列挙体かどうかを示す値を取得または設定します。
パブリック プロパティ IsInterface 型がインターフェイスかどうかを示す値を取得または設定します。
パブリック プロパティ IsPartial 型宣言が完全か部分的かを示す値を取得または設定します。
パブリック プロパティ IsStruct 型が値型 (構造体) かどうかを示す値を取得または設定します。
パブリック プロパティ LinePragma  型メンバのステートメントが発生する行を取得または設定します。(CodeTypeMember から継承されます。)
パブリック プロパティ Members 表される型のクラス メンバのコレクションを取得します。
パブリック プロパティ Name  メンバの名前を取得または設定します。(CodeTypeMember から継承されます。)
パブリック プロパティ StartDirectives  メンバの開始ディレクティブを取得します。(CodeTypeMember から継承されます。)
パブリック プロパティ TypeAttributes 型の属性を取得または設定します。
パブリック プロパティ TypeParameters 型宣言の型パラメータを取得します。
パブリック プロパティ UserData  現在のオブジェクトのユーザー定義可能なデータを取得または設定します。(CodeObject から継承されます。)
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
パブリック イベントパブリック イベント
  名前 説明
パブリック イベント PopulateBaseTypes BaseTypes コレクションが最初にアクセスされたときに発生します。
パブリック イベント PopulateMembers Members コレクションが最初にアクセスされたときに発生します。
参照参照

関連項目

CodeTypeDeclaration クラス
System.CodeDom 名前空間
CodeTypeDeclarationCollection
GeneratorSupport



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「CodeTypeDeclaration」の関連用語

CodeTypeDeclarationのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CodeTypeDeclarationのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS