Bagikan melalui


CodeStatementCollection Kelas

Definisi

Mewakili kumpulan CodeStatement objek.

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
Warisan
CodeStatementCollection
Atribut

Contoh

Contoh berikut menunjukkan cara menggunakan CodeStatementCollection kelas . Contoh membuat instans baru kelas dan menggunakan beberapa metode untuk menambahkan pernyataan ke koleksi, mengembalikan indeksnya, dan menambahkan atau menghapus pernyataan pada titik indeks tertentu.

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

Keterangan

Kelas ini CodeStatementCollection menyediakan objek koleksi sederhana yang dapat digunakan untuk menyimpan sekumpulan CodeStatement objek.

Konstruktor

CodeStatementCollection()

Menginisialisasi instans baru kelas CodeStatementCollection.

CodeStatementCollection(CodeStatement[])

Menginisialisasi instans CodeStatementCollection baru kelas yang berisi array CodeStatement objek yang ditentukan.

CodeStatementCollection(CodeStatementCollection)

Menginisialisasi instans CodeStatementCollection baru kelas yang berisi elemen koleksi sumber yang ditentukan.

Properti

Capacity

Mendapatkan atau mengatur jumlah elemen yang dapat dimuat CollectionBase .

(Diperoleh dari CollectionBase)
Count

Mendapatkan jumlah elemen yang terkandung dalam CollectionBase instans. Properti ini tidak dapat ditimpa.

(Diperoleh dari CollectionBase)
InnerList

Mendapatkan yang ArrayList berisi daftar elemen dalam CollectionBase instans.

(Diperoleh dari CollectionBase)
Item[Int32]

Mendapatkan atau mengatur CodeStatement objek pada indeks yang ditentukan dalam koleksi.

List

Mendapatkan yang IList berisi daftar elemen dalam CollectionBase instans.

(Diperoleh dari CollectionBase)

Metode

Add(CodeExpression)

Menambahkan objek yang ditentukan CodeExpression ke koleksi.

Add(CodeStatement)

Menambahkan objek yang ditentukan CodeStatement ke koleksi.

AddRange(CodeStatement[])

Menambahkan sekumpulan CodeStatement objek ke koleksi.

AddRange(CodeStatementCollection)

Menambahkan isi objek lain CodeStatementCollection ke akhir koleksi.

Clear()

Menghapus semua objek dari CollectionBase instans. Metode ini tidak dapat ditimpa.

(Diperoleh dari CollectionBase)
Contains(CodeStatement)

Mendapatkan nilai yang menunjukkan apakah koleksi berisi objek yang ditentukan CodeStatement .

CopyTo(CodeStatement[], Int32)

Menyalin elemen CodeStatementCollection objek ke instans satu dimensi Array , dimulai dari indeks yang ditentukan.

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetEnumerator()

Mengembalikan enumerator yang melakukan iterasi melalui CollectionBase instans.

(Diperoleh dari CollectionBase)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan instans Type saat ini.

(Diperoleh dari Object)
IndexOf(CodeStatement)

Mendapatkan indeks objek yang ditentukan CodeStatement di CodeStatementCollection, jika ada dalam koleksi.

Insert(Int32, CodeStatement)

Menyisipkan objek yang ditentukan CodeStatement ke dalam koleksi pada indeks yang ditentukan.

MemberwiseClone()

Membuat salinan dangkal dari yang saat ini Object.

(Diperoleh dari Object)
OnClear()

Melakukan proses kustom tambahan saat menghapus konten instans CollectionBase .

(Diperoleh dari CollectionBase)
OnClearComplete()

Melakukan proses kustom tambahan setelah menghapus konten instans CollectionBase .

(Diperoleh dari CollectionBase)
OnInsert(Int32, Object)

Melakukan proses kustom tambahan sebelum memasukkan elemen baru ke CollectionBase dalam instans.

(Diperoleh dari CollectionBase)
OnInsertComplete(Int32, Object)

Melakukan proses kustom tambahan setelah menyisipkan elemen baru ke CollectionBase dalam instans.

(Diperoleh dari CollectionBase)
OnRemove(Int32, Object)

Melakukan proses kustom tambahan saat menghapus elemen dari CollectionBase instans.

(Diperoleh dari CollectionBase)
OnRemoveComplete(Int32, Object)

Melakukan proses kustom tambahan setelah menghapus elemen dari CollectionBase instans.

(Diperoleh dari CollectionBase)
OnSet(Int32, Object, Object)

Melakukan proses kustom tambahan sebelum mengatur nilai dalam CollectionBase instans.

(Diperoleh dari CollectionBase)
OnSetComplete(Int32, Object, Object)

Melakukan proses kustom tambahan setelah menetapkan nilai dalam CollectionBase instans.

(Diperoleh dari CollectionBase)
OnValidate(Object)

Melakukan proses kustom tambahan saat memvalidasi nilai.

(Diperoleh dari CollectionBase)
Remove(CodeStatement)

Menghapus objek yang ditentukan CodeStatement dari koleksi.

RemoveAt(Int32)

Menghapus elemen pada indeks instans yang CollectionBase ditentukan. Metode ini tidak dapat diganti.

(Diperoleh dari CollectionBase)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Implementasi Antarmuka Eksplisit

ICollection.CopyTo(Array, Int32)

Menyalin seluruh CollectionBase ke satu dimensi Arrayyang kompatibel, dimulai dari indeks array target yang ditentukan.

(Diperoleh dari CollectionBase)
ICollection.IsSynchronized

Mendapatkan nilai yang menunjukkan apakah akses ke disinkronkan CollectionBase (utas aman).

(Diperoleh dari CollectionBase)
ICollection.SyncRoot

Mendapatkan objek yang dapat digunakan untuk menyinkronkan akses ke CollectionBase.

(Diperoleh dari CollectionBase)
IList.Add(Object)

Menambahkan objek ke akhir CollectionBase.

(Diperoleh dari CollectionBase)
IList.Contains(Object)

Menentukan apakah CollectionBase berisi elemen tertentu.

(Diperoleh dari CollectionBase)
IList.IndexOf(Object)

Mencari yang ditentukan Object dan mengembalikan indeks berbasis nol dari kemunculan pertama dalam seluruh CollectionBase.

(Diperoleh dari CollectionBase)
IList.Insert(Int32, Object)

Menyisipkan elemen ke dalam pada CollectionBase indeks yang ditentukan.

(Diperoleh dari CollectionBase)
IList.IsFixedSize

Mendapatkan nilai yang menunjukkan apakah CollectionBase memiliki ukuran tetap.

(Diperoleh dari CollectionBase)
IList.IsReadOnly

Mendapatkan nilai yang menunjukkan apakah CollectionBase bersifat baca-saja.

(Diperoleh dari CollectionBase)
IList.Item[Int32]

Mendapatkan atau mengatur elemen pada indeks yang ditentukan.

(Diperoleh dari CollectionBase)
IList.Remove(Object)

Menghapus kemunculan pertama objek tertentu dari CollectionBase.

(Diperoleh dari CollectionBase)

Metode Ekstensi

Cast<TResult>(IEnumerable)

Mentransmisikan elemen dari IEnumerable ke jenis yang ditentukan.

OfType<TResult>(IEnumerable)

Memfilter elemen berdasarkan IEnumerable jenis tertentu.

AsParallel(IEnumerable)

Mengaktifkan paralelisasi kueri.

AsQueryable(IEnumerable)

Mengonversi menjadi IEnumerableIQueryable.

Berlaku untuk

Lihat juga