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

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



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CodeTypeDeclaration クラス」の関連用語

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

   

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



CodeTypeDeclaration クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS