System.CodeDom.CodeTypeDeclaration Class

Represents a type declaration for a class, structure, interface, or enumeration.

See Also: CodeTypeDeclaration Members

Syntax

[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
public class CodeTypeDeclaration : CodeTypeMember

Remarks

System.CodeDom.CodeTypeDeclaration can be used to represent code that declares a class, structure, interface, or enumeration. System.CodeDom.CodeTypeDeclaration can be used to declare a type that is nested within another type.

The CodeTypeDeclaration.BaseTypes property specifies the base type or base types of the type being declared. The CodeTypeDeclaration.Members property contains the type members, which can include methods, fields, properties, comments and other types. The CodeTypeDeclaration.TypeAttributes property indicates the System.Reflection.TypeAttributes values for the type declaration, which indicate the type category of the type. The CodeTypeDeclaration.IsClass, CodeTypeDeclaration.IsStruct, CodeTypeDeclaration.IsEnum, and CodeTypeDeclaration.IsInterface methods indicate whether the type is a class, structure, enumeration, or interface type, respectively.

Note:

Some programming languages only support the declaration of reference types, or classes. To check a language-specific CodeDOM code generator for support for declaring interfaces, enumerations, or value types, call the System.CodeDom.Compiler.ICodeGenerator.Supports(System.CodeDom.Compiler.GeneratorSupport) method to test for the appropriate System.CodeDom.Compiler.GeneratorSupport flags. System.CodeDom.Compiler.GeneratorSupport.DeclareInterfaces indicates support for interfaces, System.CodeDom.Compiler.GeneratorSupport.DeclareEnums indicates support for enumerations, and System.CodeDom.Compiler.GeneratorSupport.DeclareValueTypes indicates support for value types such as structures.

You can build a class or a structure implementation in one complete declaration, or spread the implementation across multiple declarations. The CodeTypeDeclaration.IsPartial property indicates whether the type declaration is complete or partial. Not all code generators support partial type declarations, so you should test for this support by calling the System.CodeDom.Compiler.ICodeGenerator.Supports(System.CodeDom.Compiler.GeneratorSupport) method with the flag System.CodeDom.Compiler.GeneratorSupport.PartialTypes.

Requirements

Namespace: System.CodeDom
Assembly: System (in System.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0, 2.0.0.0, 4.0.0.0