CodeNamespaceImport-Klasse
Stellt eine Direktive für den Namespaceimport dar, die einen zu verwendenden Namespace angibt.
Namespace: System.CodeDom
Assembly: System (in system.dll)
Syntax
'Declaration
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeNamespaceImport
Inherits CodeObject
'Usage
Dim instance As CodeNamespaceImport
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
public class CodeNamespaceImport : CodeObject
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[ComVisibleAttribute(true)]
public ref class CodeNamespaceImport : public CodeObject
/** @attribute SerializableAttribute() */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
/** @attribute ComVisibleAttribute(true) */
public class CodeNamespaceImport extends CodeObject
SerializableAttribute
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)
ComVisibleAttribute(true)
public class CodeNamespaceImport extends CodeObject
Hinweise
Mit CodeNamespaceImport kann eine Direktive für den Namespaceimport dargestellt werden.
In den meisten Sprachen bewirkt eine Direktive zum Namespaceimport für Code, der auf Typen in den importierten Namespaces verweist, die Sichtbarkeit der Typen in den importierten Namespaces.
Hinweis
Verwenden Sie voll gekennzeichnete Typverweise, um eine mögliche Mehrdeutigkeit auszuschließen.
Beispiel
Im folgenden Beispielcode wird veranschaulicht, wie mit einem CodeNamespaceImport der CodeNamespaceImport-Namespace importiert wird.
' Declares a compile unit to contain a namespace.
Dim compileUnit As New CodeCompileUnit()
' Declares a namespace named TestNamespace.
Dim testNamespace As 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.
Dim import1 As New CodeNamespaceImport("System")
' Adds the namespace import to the namespace imports collection of the namespace.
testNamespace.Imports.Add(import1)
' A Visual Basic code generator produces the following source code for the preceeding example code:
'Option Strict Off
'Option Explicit On
'
'Imports System
'
'Namespace TestNamespace
'End 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;
//
// }
// Declares a compile unit to contain a namespace.
CodeCompileUnit^ compileUnit = gcnew CodeCompileUnit;
// Declares a namespace named TestNamespace.
CodeNamespace^ testNamespace = gcnew 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 = gcnew 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;
//
// }
// 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.get_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.get_Imports().Add(import1);
// A VJ# code generator produces the following source code for
// the preceeding example code:
// package TestNamespace;
// import System;
Vererbungshierarchie
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeNamespaceImport
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
CodeNamespaceImport-Member
System.CodeDom-Namespace
CodeNamespaceImportCollection