Freigeben über


CodeNamespaceCollection-Klasse

Stellt eine Auflistung von CodeNamespace-Objekten dar.

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

Syntax

'Declaration
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeNamespaceCollection
    Inherits CollectionBase
'Usage
Dim instance As CodeNamespaceCollection
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class CodeNamespaceCollection : CollectionBase
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class CodeNamespaceCollection : public CollectionBase
/** @attribute SerializableAttribute() */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class CodeNamespaceCollection extends CollectionBase
SerializableAttribute 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class CodeNamespaceCollection extends CollectionBase

Hinweise

Die CodeNamespaceCollection-Klasse stellt ein einfaches Auflistungsobjekt dar, das zum Speichern einer Reihe von CodeNamespace-Objekten verwendet werden kann.

Beispiel

' Creates an empty CodeNamespaceCollection.            
Dim collection As New CodeNamespaceCollection()

' Adds a CodeNamespace to the collection.
collection.Add(New CodeNamespace("TestNamespace"))

' Adds an array of CodeNamespace objects to the collection.
Dim namespaces As CodeNamespace() = {New CodeNamespace("TestNamespace1"), New CodeNamespace("TestNamespace2")}
collection.AddRange(namespaces)

' Adds a collection of CodeNamespace objects to the collection.
Dim namespacesCollection As New CodeNamespaceCollection()
namespacesCollection.Add(New CodeNamespace("TestNamespace1"))
namespacesCollection.Add(New CodeNamespace("TestNamespace2"))
collection.AddRange(namespacesCollection)

' Tests for the presence of a CodeNamespace in the collection,
' and retrieves its index if it is found.
Dim testNamespace As New CodeNamespace("TestNamespace")
Dim itemIndex As Integer = -1
If collection.Contains(testNamespace) Then
    itemIndex = collection.IndexOf(testNamespace)
End If

' Copies the contents of the collection beginning at index 0,
' to the specified CodeNamespace array.
' 'namespaces' is a CodeNamespace array.
collection.CopyTo(namespaces, 0)

' Retrieves the count of the items in the collection.
Dim collectionCount As Integer = collection.Count

' Inserts a CodeNamespace at index 0 of the collection.
collection.Insert(0, New CodeNamespace("TestNamespace"))

' Removes the specified CodeNamespace from the collection.
Dim namespace_ As New CodeNamespace("TestNamespace")
collection.Remove(namespace_)

' Removes the CodeNamespace at index 0.
collection.RemoveAt(0)
// Creates an empty CodeNamespaceCollection.            
CodeNamespaceCollection collection = new CodeNamespaceCollection();

// Adds a CodeNamespace to the collection.
collection.Add( new CodeNamespace("TestNamespace") );

// Adds an array of CodeNamespace objects to the collection.
CodeNamespace[] namespaces = { new CodeNamespace("TestNamespace1"), new CodeNamespace("TestNamespace2") };
collection.AddRange( namespaces );

// Adds a collection of CodeNamespace objects to the collection.
CodeNamespaceCollection namespacesCollection = new CodeNamespaceCollection();
namespacesCollection.Add( new CodeNamespace("TestNamespace1") );
namespacesCollection.Add( new CodeNamespace("TestNamespace2") );
collection.AddRange( namespacesCollection );

// Tests for the presence of a CodeNamespace in the collection,
// and retrieves its index if it is found.
CodeNamespace testNamespace = new CodeNamespace("TestNamespace");
int itemIndex = -1;
if( collection.Contains( testNamespace ) )
    itemIndex = collection.IndexOf( testNamespace );

// Copies the contents of the collection beginning at index 0,
// to the specified CodeNamespace array.
// 'namespaces' is a CodeNamespace array.
collection.CopyTo( namespaces, 0 );

// Retrieves the count of the items in the collection.
int collectionCount = collection.Count;

// Inserts a CodeNamespace at index 0 of the collection.
collection.Insert( 0, new CodeNamespace("TestNamespace") );

// Removes the specified CodeNamespace from the collection.
CodeNamespace namespace_ = new CodeNamespace("TestNamespace");
collection.Remove( namespace_ );

// Removes the CodeNamespace at index 0.
collection.RemoveAt(0);
// Creates an empty CodeNamespaceCollection.            
CodeNamespaceCollection^ collection = gcnew CodeNamespaceCollection;

// Adds a CodeNamespace to the collection.
collection->Add( gcnew CodeNamespace( "TestNamespace" ) );

// Adds an array of CodeNamespace objects to the collection.
array<CodeNamespace^>^namespaces = {gcnew CodeNamespace( "TestNamespace1" ),gcnew CodeNamespace( "TestNamespace2" )};
collection->AddRange( namespaces );

// Adds a collection of CodeNamespace objects to the collection.
CodeNamespaceCollection^ namespacesCollection = gcnew CodeNamespaceCollection;
namespacesCollection->Add( gcnew CodeNamespace( "TestNamespace1" ) );
namespacesCollection->Add( gcnew CodeNamespace( "TestNamespace2" ) );
collection->AddRange( namespacesCollection );

// Tests for the presence of a CodeNamespace in the collection,
// and retrieves its index if it is found.
CodeNamespace^ testNamespace = gcnew CodeNamespace( "TestNamespace" );
int itemIndex = -1;
if ( collection->Contains( testNamespace ) )
   itemIndex = collection->IndexOf( testNamespace );

// Copies the contents of the collection beginning at index 0,
// to the specified CodeNamespace array.
// 'namespaces' is a CodeNamespace array.
collection->CopyTo( namespaces, 0 );

// Retrieves the count of the items in the collection.
int collectionCount = collection->Count;

// Inserts a CodeNamespace at index 0 of the collection.
collection->Insert( 0, gcnew CodeNamespace( "TestNamespace" ) );

// Removes the specified CodeNamespace from the collection.
CodeNamespace^ namespace_ = gcnew CodeNamespace( "TestNamespace" );
collection->Remove( namespace_ );

// Removes the CodeNamespace at index 0.
collection->RemoveAt( 0 );
// Creates an empty CodeNamespaceCollection.            
CodeNamespaceCollection collection = new CodeNamespaceCollection();

// Adds a CodeNamespace to the collection.
collection.Add(new CodeNamespace("TestNamespace"));

// Adds an array of CodeNamespace objects to the collection.
CodeNamespace namespaces[] = {
    new CodeNamespace("TestNamespace1"), new 
    CodeNamespace("TestNamespace2")
};
collection.AddRange(namespaces);
// Adds a collection of CodeNamespace objects to the collection.
CodeNamespaceCollection namespacesCollection = new 
    CodeNamespaceCollection();
namespacesCollection.Add(new CodeNamespace("TestNamespace1"));
namespacesCollection.Add(new CodeNamespace("TestNamespace2"));
collection.AddRange(namespacesCollection);

// Tests for the presence of a CodeNamespace in the collection,
// and retrieves its index if it is found.
CodeNamespace testNamespace = new CodeNamespace("TestNamespace");
int itemIndex = -1;
if (collection.Contains(testNamespace)) {
    itemIndex = collection.IndexOf(testNamespace);
}

// Copies the contents of the collection beginning at index 0,
// to the specified CodeNamespace array.
// 'namespaces' is a CodeNamespace array.
collection.CopyTo(namespaces, 0);

// Retrieves the count of the items in the collection.
int collectionCount = collection.get_Count();

// Inserts a CodeNamespace at index 0 of the collection.
collection.Insert(0, new CodeNamespace("TestNamespace"));

// Removes the specified CodeNamespace from the collection.
CodeNamespace namespace_ = new CodeNamespace("TestNamespace");
collection.Remove(namespace_);

// Removes the CodeNamespace at index 0.
collection.RemoveAt(0);

Vererbungshierarchie

System.Object
   System.Collections.CollectionBase
    System.CodeDom.CodeNamespaceCollection

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

CodeNamespaceCollection-Member
System.CodeDom-Namespace
CodeNamespace-Klasse