CodeNamespaceCollection クラス
CodeNamespace オブジェクトのコレクションを表します。
名前空間: System.CodeDom
アセンブリ: System (system.dll 内)
構文
'宣言
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeNamespaceCollection
Inherits CollectionBase
'使用
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
解説
CodeNamespaceCollection クラスは、CodeNamespace オブジェクトのセットを格納するために使用できる単純なコレクション オブジェクトを提供します。
使用例
' 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);
継承階層
System.Object
System.Collections.CollectionBase
System.CodeDom.CodeNamespaceCollection
スレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
参照
関連項目
CodeNamespaceCollection メンバ
System.CodeDom 名前空間
CodeNamespace クラス