CodeStatementCollection Classe

Definizione

Rappresenta una raccolta di oggetti CodeStatement.

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
Ereditarietà
CodeStatementCollection
Attributi

Esempio

Nell'esempio riportato di seguito viene illustrato come utilizzare la classe CodeStatementCollection. Nell'esempio viene creata una nuova istanza della classe e vengono usati diversi metodi per aggiungere istruzioni alla raccolta, restituire l'indice e aggiungere o rimuovere istruzioni in un punto di indice specifico.

// 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)

Commenti

La classe CodeStatementCollection specifica un oggetto della raccolta che può essere utilizzato per archiviare un set di oggetti CodeStatement.

Costruttori

CodeStatementCollection()

Inizializza una nuova istanza della classe CodeStatementCollection.

CodeStatementCollection(CodeStatement[])

Consente l'inizializzazione di una nuova istanza della classe CodeStatementCollection contenente la matrice specificata di oggetti CodeStatement.

CodeStatementCollection(CodeStatementCollection)

Inizializza una nuova istanza della classe CodeStatementCollection contenente gli elementi dell'insieme di origine specificato.

Proprietà

Capacity

Ottiene o imposta il numero di elementi che CollectionBase può contenere.

(Ereditato da CollectionBase)
Count

Ottiene il numero di elementi contenuti nell'istanza di CollectionBase. Questa proprietà non può essere sottoposta a override.

(Ereditato da CollectionBase)
InnerList

Ottiene un ArrayList contenente l'elenco degli elementi presenti nell'istanza CollectionBase.

(Ereditato da CollectionBase)
Item[Int32]

Ottiene o imposta l'oggetto CodeStatement nella raccolta, in corrispondenza dell'indice specificato.

List

Ottiene un IList contenente l'elenco degli elementi presenti nell'istanza CollectionBase.

(Ereditato da CollectionBase)

Metodi

Add(CodeExpression)

Aggiunge l'oggetto CodeExpression specificato alla raccolta.

Add(CodeStatement)

Aggiunge l'oggetto CodeStatement specificato alla raccolta.

AddRange(CodeStatement[])

Aggiunge un gruppo di oggetti CodeStatement alla raccolta.

AddRange(CodeStatementCollection)

Aggiunge il contenuto di un altro oggetto CodeStatementCollection alla fine dell'insieme.

Clear()

Consente di rimuovere tutti gli oggetti dall'istanza CollectionBase. Questo metodo non può essere sottoposto a override.

(Ereditato da CollectionBase)
Contains(CodeStatement)

Ottiene un valore che indica se l'insieme contiene l'oggetto CodeStatement specificato.

CopyTo(CodeStatement[], Int32)

Copia gli elementi dell'oggetto CodeStatementCollection in un'istanza di Array unidimensionale, a partire dall'indice specificato.

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetEnumerator()

Restituisce un enumeratore per lo scorrimento dell'istanza di CollectionBase.

(Ereditato da CollectionBase)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
IndexOf(CodeStatement)

Ottiene l'indice dell'oggetto CodeStatement specificato in CodeStatementCollection, se esistente.

Insert(Int32, CodeStatement)

Inserisce l'oggetto CodeStatement specificato nella raccolta in corrispondenza dell'indice specificato.

MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
OnClear()

Esegue processi personalizzati aggiuntivi quando viene cancellato il contenuto dell'istanza di CollectionBase.

(Ereditato da CollectionBase)
OnClearComplete()

Esegue procedure personalizzate aggiuntive prima di cancellare il contenuto dell'istanza di CollectionBase.

(Ereditato da CollectionBase)
OnInsert(Int32, Object)

Esegue procedure personalizzate aggiuntive prima di inserire un nuovo elemento nell'istanza di CollectionBase.

(Ereditato da CollectionBase)
OnInsertComplete(Int32, Object)

Esegue procedure personalizzate aggiuntive dopo aver inserito un nuovo elemento nell'istanza di CollectionBase.

(Ereditato da CollectionBase)
OnRemove(Int32, Object)

Consente di eseguire procedure personalizzate aggiuntive durante l'eliminazione di un elemento dall'istanza CollectionBase.

(Ereditato da CollectionBase)
OnRemoveComplete(Int32, Object)

Esegue procedure personalizzate aggiuntive dopo della rimozione di un elemento dall'istanza di CollectionBase.

(Ereditato da CollectionBase)
OnSet(Int32, Object, Object)

Esegue procedure personalizzate aggiuntive prima di impostare un valore nell'istanza di CollectionBase.

(Ereditato da CollectionBase)
OnSetComplete(Int32, Object, Object)

Esegue procedure personalizzate aggiuntive dopo aver impostato un valore nell'istanza di CollectionBase.

(Ereditato da CollectionBase)
OnValidate(Object)

Esegue processi personalizzati aggiuntivi durante la convalida di un valore.

(Ereditato da CollectionBase)
Remove(CodeStatement)

Rimuove l'oggetto CodeStatement specificato dalla raccolta.

RemoveAt(Int32)

Consente di rimuovere la voce in corrispondenza dell'indice specificato dell'istanza CollectionBase. Questo metodo non può essere sottoposto a override.

(Ereditato da CollectionBase)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Implementazioni dell'interfaccia esplicita

ICollection.CopyTo(Array, Int32)

Copia l'intero oggetto CollectionBase in un oggetto Array compatibile unidimensionale, a partire dall'indice specificato della matrice di destinazione.

(Ereditato da CollectionBase)
ICollection.IsSynchronized

Ottiene un valore che indica se l'accesso a CollectionBase è sincronizzato (thread-safe).

(Ereditato da CollectionBase)
ICollection.SyncRoot

Ottiene un oggetto che può essere usato per sincronizzare l'accesso a CollectionBase.

(Ereditato da CollectionBase)
IList.Add(Object)

Aggiunge un oggetto alla fine di CollectionBase.

(Ereditato da CollectionBase)
IList.Contains(Object)

Consente di stabilire se CollectionBase contiene un elemento specifico.

(Ereditato da CollectionBase)
IList.IndexOf(Object)

Cerca l'oggetto Object specificato e restituisce l'indice in base zero della prima occorrenza all'interno dell'intero CollectionBase.

(Ereditato da CollectionBase)
IList.Insert(Int32, Object)

Inserisce un elemento in CollectionBase in corrispondenza dell'indice specificato.

(Ereditato da CollectionBase)
IList.IsFixedSize

Ottiene un valore che indica se CollectionBase ha dimensioni fisse.

(Ereditato da CollectionBase)
IList.IsReadOnly

Ottiene un valore che indica se CollectionBase è di sola lettura.

(Ereditato da CollectionBase)
IList.Item[Int32]

Ottiene o imposta l'elemento in corrispondenza dell'indice specificato.

(Ereditato da CollectionBase)
IList.Remove(Object)

Rimuove la prima occorrenza di un oggetto specifico da CollectionBase.

(Ereditato da CollectionBase)

Metodi di estensione

Cast<TResult>(IEnumerable)

Esegue il cast degli elementi di un oggetto IEnumerable nel tipo specificato.

OfType<TResult>(IEnumerable)

Filtra gli elementi di un oggetto IEnumerable in base a un tipo specificato.

AsParallel(IEnumerable)

Consente la parallelizzazione di una query.

AsQueryable(IEnumerable)

Converte un oggetto IEnumerable in un oggetto IQueryable.

Si applica a

Vedi anche