CodeNamespaceImport Class

 

Represents a namespace import directive that indicates a namespace to use.

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

System.Object
  System.CodeDom.CodeObject
    System.CodeDom.CodeNamespaceImport

[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
public class CodeNamespaceImport : CodeObject

NameDescription
System_CAPS_pubmethodCodeNamespaceImport()

Initializes a new instance of the CodeNamespaceImport class.

System_CAPS_pubmethodCodeNamespaceImport(String)

Initializes a new instance of the CodeNamespaceImport class using the specified namespace to import.

NameDescription
System_CAPS_pubpropertyLinePragma

Gets or sets the line and file the statement occurs on.

System_CAPS_pubpropertyNamespace

Gets or sets the namespace to import.

System_CAPS_pubpropertyUserData

Gets the user-definable data for the current object.(Inherited from CodeObject.)

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

CodeNamespaceImport can be used to represent a namespace import directive.

In most languages, a namespace import directive causes visibility of the types within the imported namespaces to code that references types in the imported namespaces.

System_CAPS_noteNote

Use fully qualified type references to avoid potential ambiguity.

The following example code demonstrates use of a CodeNamespaceImport to import the CodeNamespaceImport namespace:

// Declares a compile unit to contain a namespace.
CodeCompileUnit compileUnit = new CodeCompileUnit();

// Declares a namespace named TestNamespace.
CodeNamespace testNamespace = new CodeNamespace("TestNamespace");
// Adds the namespace to the namespace collection of the compile unit.
compileUnit.Namespaces.Add(testNamespace);

// Declares a namespace import of the System namespace.
CodeNamespaceImport import1 = new CodeNamespaceImport("System");
// Adds the namespace import to the namespace imports collection of the namespace.
testNamespace.Imports.Add(import1);

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

//    namespace TestNamespace {        
//        using System;
//
//  }

.NET Framework
Available since 1.1

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

Return to top
Show: