クラス、構造体、インターフェイス、または列挙体の型宣言を表します。
この型のすべてのメンバの一覧については、CodeTypeDeclaration メンバ を参照してください。
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeTypeMember
System.CodeDom.CodeTypeDeclaration
System.CodeDom.CodeTypeDelegate
<Serializable>
<ClassInterface(ClassInterfaceType.AutoDispatch)>
<ComVisible(True)>
Public Class CodeTypeDeclaration Inherits CodeTypeMember
[C#]
[Serializable]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ComVisible(true)]
public class CodeTypeDeclaration : CodeTypeMember
[C++]
[Serializable]
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ComVisible(true)]
public __gc class CodeTypeDeclaration : public CodeTypeMember
[JScript]
public
Serializable
ClassInterface(ClassInterfaceType.AutoDispatch)
ComVisible(true)
class CodeTypeDeclaration extends CodeTypeMember
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
CodeTypeDeclaration を使用して、クラス、構造体、インターフェイス、または列挙体を宣言するコードを表すことができます。 CodeTypeDeclaration を使用して、別の型の中に入れ子になった型を宣言できます。
BaseTypes プロパティは、宣言される型の 1 つ以上の基本型を指定します。 Members プロパティは、型のメンバを格納します。これには、メソッド、フィールド、プロパティ、コメント、および他の型があります。 TypeAttributes プロパティは、型宣言の TypeAttributes 値を示します。これはその型のカテゴリを示します。 IsClass 、 IsStruct 、 IsEnum 、および IsInterface の各メソッドはそれぞれ、その型がクラス、構造体、列挙体、またはインターフェイスの型かどうかを示します。
メモ プログラミング言語によっては、参照型またはクラスの宣言しかサポートされないこともあります。言語固有の CodeDOM コード ジェネレータがインターフェイス、列挙体、または値型の宣言をサポートしているかどうかを調べるには、 Supports メソッドを呼び出して該当する GeneratorSupport フラグを調べます。 DeclareInterfaces はインターフェイスのサポートを示し、 DeclareEnums は列挙体のサポートを示し、 DeclareValueTypes は構造体などの値型のサポートを示します。
使用例
[Visual Basic, C#, C++] 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
[C#]
// 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
// {
// }
[C++]
// Creates a new type declaration.
CodeTypeDeclaration* newType = new CodeTypeDeclaration(
// name parameter indicates the name of the type.
S"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( S"BaseType" );
// A C# code generator produces the following source code for the preceeding example code:
// class TestType : BaseType
// {
// }
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.CodeDom
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System (System.dll 内)
参照
CodeTypeDeclaration メンバ | System.CodeDom 名前空間 | CodeTypeDeclarationCollection