Freigeben über


CodeTypeMemberCollection-Klasse

Stellt eine Auflistung von CodeTypeMember-Objekten dar.

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

Syntax

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

Hinweise

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

Beispiel

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

' Adds a CodeTypeMember to the collection.
collection.Add(New CodeMemberField("System.String", "TestStringField"))

' Adds an array of CodeTypeMember objects to the collection.
Dim members As CodeTypeMember() = {New CodeMemberField("System.String", "TestStringField1"), New CodeMemberField("System.String", "TestStringField2")}
collection.AddRange(members)

' Adds a collection of CodeTypeMember objects to the collection.
Dim membersCollection As New CodeTypeMemberCollection()
membersCollection.Add(New CodeMemberField("System.String", "TestStringField1"))
membersCollection.Add(New CodeMemberField("System.String", "TestStringField2"))
collection.AddRange(membersCollection)

' Tests for the presence of a CodeTypeMember within the collection, and retrieves its index if it is within the collection.
Dim testMember = New CodeMemberField("System.String", "TestStringField")
Dim itemIndex As Integer = -1
If collection.Contains(testMember) Then
    itemIndex = collection.IndexOf(testMember)
End If

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

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

' Inserts a CodeTypeMember at index 0 of the collection.
collection.Insert(0, New CodeMemberField("System.String", "TestStringField"))

' Removes the specified CodeTypeMember from the collection.
Dim member = New CodeMemberField("System.String", "TestStringField")
collection.Remove(member)

' Removes the CodeTypeMember at index 0.
collection.RemoveAt(0)
// Creates an empty CodeTypeMemberCollection.
CodeTypeMemberCollection collection = new CodeTypeMemberCollection();
         
// Adds a CodeTypeMember to the collection.
collection.Add( new CodeMemberField("System.String", "TestStringField") );

// Adds an array of CodeTypeMember objects to the collection.
CodeTypeMember[] members = { new CodeMemberField("System.String", "TestStringField1"), new CodeMemberField("System.String", "TestStringField2") };
collection.AddRange( members );

// Adds a collection of CodeTypeMember objects to the collection.
CodeTypeMemberCollection membersCollection = new CodeTypeMemberCollection();
membersCollection.Add( new CodeMemberField("System.String", "TestStringField1") );
membersCollection.Add( new CodeMemberField("System.String", "TestStringField2") );
collection.AddRange( membersCollection );

// Tests for the presence of a CodeTypeMember in the collection, 
// and retrieves its index if it is found.
CodeTypeMember testMember = new CodeMemberField("System.String", "TestStringField");
int itemIndex = -1;
if( collection.Contains( testMember ) )
    itemIndex = collection.IndexOf( testMember );

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

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

// Inserts a CodeTypeMember at index 0 of the collection.
collection.Insert( 0, new CodeMemberField("System.String", "TestStringField") );

// Removes the specified CodeTypeMember from the collection.
CodeTypeMember member = new CodeMemberField("System.String", "TestStringField");
collection.Remove( member );

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

// Adds a CodeTypeMember to the collection.
collection->Add( gcnew CodeMemberField( "System.String","TestStringField" ) );

// Adds an array of CodeTypeMember objects to the collection.
array<CodeTypeMember^>^members = {gcnew CodeMemberField( "System.String","TestStringField1" ),gcnew CodeMemberField( "System.String","TestStringField2" )};
collection->AddRange( members );

// Adds a collection of CodeTypeMember objects to the collection.
CodeTypeMemberCollection^ membersCollection = gcnew CodeTypeMemberCollection;
membersCollection->Add( gcnew CodeMemberField( "System.String","TestStringField1" ) );
membersCollection->Add( gcnew CodeMemberField( "System.String","TestStringField2" ) );
collection->AddRange( membersCollection );

// Tests for the presence of a CodeTypeMember in the collection, 
// and retrieves its index if it is found.
CodeTypeMember^ testMember = gcnew CodeMemberField( "System.String","TestStringField" );
int itemIndex = -1;
if ( collection->Contains( testMember ) )
   itemIndex = collection->IndexOf( testMember );

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

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

// Inserts a CodeTypeMember at index 0 of the collection.
collection->Insert( 0, gcnew CodeMemberField( "System.String","TestStringField" ) );

// Removes the specified CodeTypeMember from the collection.
CodeTypeMember^ member = gcnew CodeMemberField( "System.String","TestStringField" );
collection->Remove( member );

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

// Adds a CodeTypeMember to the collection.
collection.Add(new CodeMemberField("System.String", "TestStringField"));

// Adds an array of CodeTypeMember objects to the collection.
CodeTypeMember members[] =  { new CodeMemberField("System.String",
    "TestStringField1"), new CodeMemberField("System.String",
    "TestStringField2") };
collection.AddRange(members);
// Adds a collection of CodeTypeMember objects to the collection.
CodeTypeMemberCollection membersCollection = new 
    CodeTypeMemberCollection();
membersCollection.Add(new CodeMemberField("System.String", 
    "TestStringField1"));
membersCollection.Add(new CodeMemberField("System.String",
    "TestStringField2"));
collection.AddRange(membersCollection);

// Tests for the presence of a CodeTypeMember in the collection, 
// and retrieves its index if it is found.
CodeTypeMember testMember = new CodeMemberField("System.String", 
    "TestStringField");
int itemIndex = -1;
if (collection.Contains(testMember)) {
    itemIndex = collection.IndexOf(testMember);
}

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

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

// Inserts a CodeTypeMember at index 0 of the collection.
collection.Insert(0, new CodeMemberField("System.String",
    "TestStringField"));

// Removes the specified CodeTypeMember from the collection.
CodeTypeMember member = new CodeMemberField("System.String",
    "TestStringField");
collection.Remove(member);

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

Vererbungshierarchie

System.Object
   System.Collections.CollectionBase
    System.CodeDom.CodeTypeMemberCollection

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

CodeTypeMemberCollection-Member
System.CodeDom-Namespace
CodeTypeMember-Klasse