Export (0) Print
Expand All

CodeTypeDeclaration Class

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

Namespace:  System.CodeDom
Assembly:  System (in System.dll)

[<SerializableAttribute>]
[<ComVisibleAttribute(true)>]
[<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)>]
type CodeTypeDeclaration =  
    class 
        inherit CodeTypeMember 
    end

The CodeTypeDeclaration type exposes the following members.

  NameDescription
Public methodCodeTypeDeclaration()Initializes a new instance of the CodeTypeDeclaration class.
Public methodCodeTypeDeclaration(String)Initializes a new instance of the CodeTypeDeclaration class with the specified name.
Top

  NameDescription
Public propertyAttributesGets or sets the attributes of the member. (Inherited from CodeTypeMember.)
Public propertyBaseTypesGets the base types of the type.
Public propertyCommentsGets the collection of comments for the type member. (Inherited from CodeTypeMember.)
Public propertyCustomAttributesGets or sets the custom attributes of the member. (Inherited from CodeTypeMember.)
Public propertyEndDirectivesGets the end directives for the member. (Inherited from CodeTypeMember.)
Public propertyIsClassGets or sets a value indicating whether the type is a class or reference type.
Public propertyIsEnumGets or sets a value indicating whether the type is an enumeration.
Public propertyIsInterfaceGets or sets a value indicating whether the type is an interface.
Public propertyIsPartialGets or sets a value indicating whether the type declaration is complete or partial.
Public propertyIsStructGets or sets a value indicating whether the type is a value type (struct).
Public propertyLinePragmaGets or sets the line on which the type member statement occurs. (Inherited from CodeTypeMember.)
Public propertyMembersGets the collection of class members for the represented type.
Public propertyNameGets or sets the name of the member. (Inherited from CodeTypeMember.)
Public propertyStartDirectivesGets the start directives for the member. (Inherited from CodeTypeMember.)
Public propertyTypeAttributesGets or sets the attributes of the type.
Public propertyTypeParametersGets the type parameters for the type declaration.
Public propertyUserDataGets the user-definable data for the current object. (Inherited from CodeObject.)
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public eventPopulateBaseTypesOccurs when the BaseTypes collection is accessed for the first time.
Public eventPopulateMembersOccurs when the Members collection is accessed for the first time.
Top

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

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

NoteNote

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 Supports method to test for the appropriate GeneratorSupport flags. DeclareInterfaces indicates support for interfaces, DeclareEnums indicates support for enumerations, and 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 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 Supports method with the flag PartialTypes.

This example demonstrates using a CodeTypeDeclaration to declare a type.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft