CodeStatementCollection Klasa

Definicja

Reprezentuje kolekcję CodeStatement obiektów.

public ref class CodeStatementCollection : System::Collections::CollectionBase
public class CodeStatementCollection : System.Collections.CollectionBase
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeStatementCollection : System.Collections.CollectionBase
type CodeStatementCollection = class
    inherit CollectionBase
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeStatementCollection = class
    inherit CollectionBase
Public Class CodeStatementCollection
Inherits CollectionBase
Dziedziczenie
CodeStatementCollection
Atrybuty

Przykłady

W poniższym przykładzie pokazano, jak używać CodeStatementCollection klasy . Przykład tworzy nowe wystąpienie klasy i używa kilku metod do dodawania instrukcji do kolekcji, zwracania indeksu i dodawania lub usuwania instrukcji w określonym punkcie indeksu.

// Creates an empty CodeStatementCollection.
CodeStatementCollection^ collection = gcnew CodeStatementCollection;

// Adds a CodeStatement to the collection.
collection->Add( gcnew CodeCommentStatement( "Test comment statement" ) );

// Adds an array of CodeStatement objects to the collection.
array<CodeStatement^>^statements = {gcnew CodeCommentStatement( "Test comment statement" ),gcnew CodeCommentStatement( "Test comment statement" )};
collection->AddRange( statements );

// Adds a collection of CodeStatement objects to the collection.
CodeStatement^ testStatement = gcnew CodeCommentStatement( "Test comment statement" );
CodeStatementCollection^ statementsCollection = gcnew CodeStatementCollection;
statementsCollection->Add( gcnew CodeCommentStatement( "Test comment statement" ) );
statementsCollection->Add( gcnew CodeCommentStatement( "Test comment statement" ) );
statementsCollection->Add( testStatement );
collection->AddRange( statementsCollection );

// Tests for the presence of a CodeStatement in the 
// collection, and retrieves its index if it is found.
int itemIndex = -1;
if ( collection->Contains( testStatement ) )
   itemIndex = collection->IndexOf( testStatement );

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

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

// Inserts a CodeStatement at index 0 of the collection.
collection->Insert( 0, gcnew CodeCommentStatement( "Test comment statement" ) );

// Removes the specified CodeStatement from the collection.
collection->Remove( testStatement );

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

// Adds a CodeStatement to the collection.
collection.Add( new CodeCommentStatement("Test comment statement") );

// Adds an array of CodeStatement objects to the collection.
CodeStatement[] statements = {
                new CodeCommentStatement("Test comment statement"),
                new CodeCommentStatement("Test comment statement")};
collection.AddRange( statements );

// Adds a collection of CodeStatement objects to the collection.
CodeStatement testStatement = new CodeCommentStatement("Test comment statement");
CodeStatementCollection statementsCollection = new CodeStatementCollection();
statementsCollection.Add( new CodeCommentStatement("Test comment statement") );
statementsCollection.Add( new CodeCommentStatement("Test comment statement") );
statementsCollection.Add( testStatement );

collection.AddRange( statementsCollection );

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


// Copies the contents of the collection beginning at index 0 to the specified CodeStatement array.
// 'statements' is a CodeStatement array.
CodeStatement[] statementArray = new CodeStatement[collection.Count];
collection.CopyTo( statementArray, 0 );

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

// Inserts a CodeStatement at index 0 of the collection.
collection.Insert( 0, new CodeCommentStatement("Test comment statement") );

// Removes the specified CodeStatement from the collection.
collection.Remove( testStatement );

// Removes the CodeStatement at index 0.
collection.RemoveAt(0);
' Creates an empty CodeStatementCollection.
Dim collection As New CodeStatementCollection

' Adds a CodeStatement to the collection.
collection.Add(New CodeCommentStatement("Test comment statement"))

' Adds an array of CodeStatement objects to the collection.
Dim statements As CodeStatement() = {New CodeCommentStatement("Test comment statement"), New CodeCommentStatement("Test comment statement")}
collection.AddRange(statements)

' Adds a collection of CodeStatement objects to the collection.
Dim testStatement As New CodeStatement
Dim statementsCollection As New CodeStatementCollection
statementsCollection.Add(New CodeCommentStatement("Test comment statement"))
statementsCollection.Add(New CodeCommentStatement("Test comment statement"))
statementsCollection.Add(testStatement)
collection.AddRange(statementsCollection)

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

' Copies the contents of the collection beginning at index 0 to the specified CodeStatement array.
' 'statements' is a CodeStatement array.
Dim statementArray(collection.Count - 1) As CodeStatement
collection.CopyTo(statementArray, 0)

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

' Inserts a CodeStatement at index 0 of the collection.
collection.Insert(0, New CodeCommentStatement("Test comment statement"))

' Removes the specified CodeStatement from the collection.
collection.Remove(testStatement)

' Removes the CodeStatement at index 0.
collection.RemoveAt(0)

Uwagi

Klasa CodeStatementCollection udostępnia prosty obiekt kolekcji, który może służyć do przechowywania zestawu CodeStatement obiektów.

Konstruktory

CodeStatementCollection()

Inicjuje nowe wystąpienie klasy CodeStatementCollection.

CodeStatementCollection(CodeStatement[])

Inicjuje CodeStatementCollection nowe wystąpienie klasy zawierającej określoną tablicę CodeStatement obiektów.

CodeStatementCollection(CodeStatementCollection)

Inicjuje CodeStatementCollection nowe wystąpienie klasy zawierające elementy określonej kolekcji źródłowej.

Właściwości

Capacity

Pobiera lub ustawia liczbę elementów, które CollectionBase mogą zawierać.

(Odziedziczone po CollectionBase)
Count

Pobiera liczbę elementów zawartych w wystąpieniu CollectionBase . Tej właściwości nie można zastąpić.

(Odziedziczone po CollectionBase)
InnerList

Pobiera obiekt ArrayList zawierający listę elementów w wystąpieniu CollectionBase .

(Odziedziczone po CollectionBase)
Item[Int32]

Pobiera lub ustawia CodeStatement obiekt w określonym indeksie w kolekcji.

List

Pobiera obiekt IList zawierający listę elementów w wystąpieniu CollectionBase .

(Odziedziczone po CollectionBase)

Metody

Add(CodeExpression)

Dodaje określony CodeExpression obiekt do kolekcji.

Add(CodeStatement)

Dodaje określony CodeStatement obiekt do kolekcji.

AddRange(CodeStatement[])

Dodaje zestaw CodeStatement obiektów do kolekcji.

AddRange(CodeStatementCollection)

Dodaje zawartość innego CodeStatementCollection obiektu na końcu kolekcji.

Clear()

Usuwa wszystkie obiekty z CollectionBase wystąpienia. Tej metody nie można zastąpić.

(Odziedziczone po CollectionBase)
Contains(CodeStatement)

Pobiera wartość wskazującą, czy kolekcja zawiera określony CodeStatement obiekt.

CopyTo(CodeStatement[], Int32)

Kopiuje elementy CodeStatementCollection obiektu do wystąpienia jednowymiarowego Array , zaczynając od określonego indeksu.

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetEnumerator()

Zwraca moduł wyliczający, który iteruje po wystąpieniu CollectionBase .

(Odziedziczone po CollectionBase)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
IndexOf(CodeStatement)

Pobiera indeks określonego CodeStatement obiektu w CodeStatementCollectionobiekcie , jeśli istnieje w kolekcji.

Insert(Int32, CodeStatement)

Wstawia określony CodeStatement obiekt do kolekcji w określonym indeksie.

MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
OnClear()

Wykonuje dodatkowe procesy niestandardowe podczas czyszczenia zawartości CollectionBase wystąpienia.

(Odziedziczone po CollectionBase)
OnClearComplete()

Wykonuje dodatkowe procesy niestandardowe po wyczyszczeniu zawartości CollectionBase wystąpienia.

(Odziedziczone po CollectionBase)
OnInsert(Int32, Object)

Wykonuje dodatkowe procesy niestandardowe przed wstawieniem nowego elementu do CollectionBase wystąpienia.

(Odziedziczone po CollectionBase)
OnInsertComplete(Int32, Object)

Wykonuje dodatkowe procesy niestandardowe po wstawieniu nowego elementu do CollectionBase wystąpienia.

(Odziedziczone po CollectionBase)
OnRemove(Int32, Object)

Wykonuje dodatkowe procesy niestandardowe podczas usuwania elementu z CollectionBase wystąpienia.

(Odziedziczone po CollectionBase)
OnRemoveComplete(Int32, Object)

Wykonuje dodatkowe procesy niestandardowe po usunięciu CollectionBase elementu z wystąpienia.

(Odziedziczone po CollectionBase)
OnSet(Int32, Object, Object)

Wykonuje dodatkowe procesy niestandardowe przed ustawieniem wartości w wystąpieniu CollectionBase .

(Odziedziczone po CollectionBase)
OnSetComplete(Int32, Object, Object)

Wykonuje dodatkowe procesy niestandardowe po ustawieniu wartości w wystąpieniu CollectionBase .

(Odziedziczone po CollectionBase)
OnValidate(Object)

Wykonuje dodatkowe procesy niestandardowe podczas sprawdzania poprawności wartości.

(Odziedziczone po CollectionBase)
Remove(CodeStatement)

Usuwa określony CodeStatement obiekt z kolekcji.

RemoveAt(Int32)

Usuwa element w określonym indeksie CollectionBase wystąpienia. Ta metoda nie jest zastępowalna.

(Odziedziczone po CollectionBase)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

ICollection.CopyTo(Array, Int32)

Kopiuje całość CollectionBase do zgodnego jednowymiarowego Arrayobiektu , zaczynając od określonego indeksu tablicy docelowej.

(Odziedziczone po CollectionBase)
ICollection.IsSynchronized

Pobiera wartość wskazującą, czy dostęp do elementu CollectionBase jest synchronizowany (bezpieczny wątk).

(Odziedziczone po CollectionBase)
ICollection.SyncRoot

Pobiera obiekt, który może służyć do synchronizowania dostępu do obiektu CollectionBase.

(Odziedziczone po CollectionBase)
IList.Add(Object)

Dodaje obiekt na końcu obiektu CollectionBase.

(Odziedziczone po CollectionBase)
IList.Contains(Object)

Określa, czy element CollectionBase zawiera określony element.

(Odziedziczone po CollectionBase)
IList.IndexOf(Object)

Wyszukuje określony Object element i zwraca indeks oparty na zerze pierwszego wystąpienia w całym CollectionBaseobiekcie .

(Odziedziczone po CollectionBase)
IList.Insert(Int32, Object)

Wstawia element do określonego indeksu CollectionBase .

(Odziedziczone po CollectionBase)
IList.IsFixedSize

Pobiera wartość wskazującą, czy ma CollectionBase stały rozmiar.

(Odziedziczone po CollectionBase)
IList.IsReadOnly

Pobiera wartość wskazującą, czy kolekcja CollectionBase jest przeznaczona tylko do odczytu.

(Odziedziczone po CollectionBase)
IList.Item[Int32]

Pobiera lub ustawia element pod określonym indeksem.

(Odziedziczone po CollectionBase)
IList.Remove(Object)

Usuwa pierwsze wystąpienie określonego obiektu z obiektu CollectionBase.

(Odziedziczone po CollectionBase)

Metody rozszerzania

Cast<TResult>(IEnumerable)

Rzutuje elementy obiektu IEnumerable na określony typ.

OfType<TResult>(IEnumerable)

Filtruje elementy IEnumerable elementu na podstawie określonego typu.

AsParallel(IEnumerable)

Umożliwia równoległość zapytania.

AsQueryable(IEnumerable)

Konwertuje element IEnumerable na .IQueryable

Dotyczy

Zobacz też