CodeExpressionCollection 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表一組 CodeExpression 物件。
public ref class CodeExpressionCollection : System::Collections::CollectionBase
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeExpressionCollection : System.Collections.CollectionBase
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeExpressionCollection = class
inherit CollectionBase
Public Class CodeExpressionCollection
Inherits CollectionBase
- 繼承
- 屬性
範例
以下範例展示了類別方法的使用 CodeExpressionCollection 。 範例會建立一個新的類別實例,並利用這些方法將語句加入集合、回傳其索引,以及在特定索引點新增或移除屬性。
// Creates an empty CodeExpressionCollection.
CodeExpressionCollection collection = new CodeExpressionCollection();
// Adds a CodeExpression to the collection.
collection.Add( new CodePrimitiveExpression(true) );
// Adds an array of CodeExpression objects to the collection.
CodeExpression[] expressions = { new CodePrimitiveExpression(true), new CodePrimitiveExpression(true) };
collection.AddRange( expressions );
// Adds a collection of CodeExpression objects to the collection.
CodeExpressionCollection expressionsCollection = new CodeExpressionCollection();
expressionsCollection.Add( new CodePrimitiveExpression(true) );
expressionsCollection.Add( new CodePrimitiveExpression(true) );
collection.AddRange( expressionsCollection );
// Tests for the presence of a CodeExpression in the
// collection, and retrieves its index if it is found.
CodeExpression testComment = new CodePrimitiveExpression(true);
int itemIndex = -1;
if( collection.Contains( testComment ) )
itemIndex = collection.IndexOf( testComment );
// Copies the contents of the collection beginning at index 0 to the specified CodeExpression array.
// 'expressions' is a CodeExpression array.
collection.CopyTo( expressions, 0 );
// Retrieves the count of the items in the collection.
int collectionCount = collection.Count;
// Inserts a CodeExpression at index 0 of the collection.
collection.Insert( 0, new CodePrimitiveExpression(true) );
// Removes the specified CodeExpression from the collection.
CodeExpression expression = new CodePrimitiveExpression(true);
collection.Remove( expression );
// Removes the CodeExpression at index 0.
collection.RemoveAt(0);
' Creates an empty CodeExpressionCollection.
Dim collection As New CodeExpressionCollection()
' Adds a CodeExpression to the collection.
collection.Add(New CodePrimitiveExpression(True))
' Adds an array of CodeExpression objects to the collection.
Dim expressions As CodeExpression() = {New CodePrimitiveExpression(True), New CodePrimitiveExpression(True)}
collection.AddRange(expressions)
' Adds a collection of CodeExpression objects to the collection.
Dim expressionsCollection As New CodeExpressionCollection()
expressionsCollection.Add(New CodePrimitiveExpression(True))
expressionsCollection.Add(New CodePrimitiveExpression(True))
collection.AddRange(expressionsCollection)
' Tests for the presence of a CodeExpression in the
' collection, and retrieves its index if it is found.
Dim testComment = New CodePrimitiveExpression(True)
Dim itemIndex As Integer = -1
If collection.Contains(testComment) Then
itemIndex = collection.IndexOf(testComment)
End If
' Copies the contents of the collection beginning at index 0 to the specified CodeExpression array.
' 'expressions' is a CodeExpression array.
collection.CopyTo(expressions, 0)
' Retrieves the count of the items in the collection.
Dim collectionCount As Integer = collection.Count
' Inserts a CodeExpression at index 0 of the collection.
collection.Insert(0, New CodePrimitiveExpression(True))
' Removes the specified CodeExpression from the collection.
Dim expression = New CodePrimitiveExpression(True)
collection.Remove(expression)
' Removes the CodeExpression at index 0.
collection.RemoveAt(0)
備註
提供一個簡單的集合物件,可代表一組程式碼文件物件模型(CodeDOM)表達物件。
這個 CodeExpressionCollection 類別提供了一個簡單的集合物件,可以用來儲存一組 CodeExpression 物件。
建構函式
| 名稱 | Description |
|---|---|
| CodeExpressionCollection() |
初始化 CodeExpressionCollection 類別的新執行個體。 |
| CodeExpressionCollection(CodeExpression[]) |
初始化包含指定物件陣列CodeExpression的CodeExpressionCollection類別新實例。 |
| CodeExpressionCollection(CodeExpressionCollection) |
初始化包含指定原始集合元素的類別新實例 CodeExpressionCollection 。 |
屬性
| 名稱 | Description |
|---|---|
| Capacity |
取得或設定 可以 CollectionBase 包含的元素數量。 (繼承來源 CollectionBase) |
| Count |
取得該實例中包含 CollectionBase 的元素數量。 此屬性無法覆寫。 (繼承來源 CollectionBase) |
| InnerList |
取得包含實ArrayList例中元素清單的 。CollectionBase (繼承來源 CollectionBase) |
| Item[Int32] |
取得或設定 CodeExpression 物件在集合中指定的索引位置。 |
| List |
取得包含實IList例中元素清單的 。CollectionBase (繼承來源 CollectionBase) |
方法
明確介面實作
| 名稱 | Description |
|---|---|
| ICollection.CopyTo(Array, Int32) |
從目標陣列指定的索引開始,將整個 CollectionBase 複製到相容的一維 Array。 (繼承來源 CollectionBase) |
| ICollection.IsSynchronized |
取得值,指出是否同步存取 CollectionBase (線程安全)。 (繼承來源 CollectionBase) |
| ICollection.SyncRoot |
取得一個物件,可用來同步存取 CollectionBase。 (繼承來源 CollectionBase) |
| IList.Add(Object) |
在 的末尾 CollectionBase加上一個物件。 (繼承來源 CollectionBase) |
| IList.Contains(Object) |
判斷是否 CollectionBase 包含特定元素。 (繼承來源 CollectionBase) |
| IList.IndexOf(Object) |
搜尋指定的 Object ,並返回整個 CollectionBase中首次出現的零基索引。 (繼承來源 CollectionBase) |
| IList.Insert(Int32, Object) |
在指定的索引處插入一個元素 CollectionBase 。 (繼承來源 CollectionBase) |
| IList.IsFixedSize |
會得到一個值,表示 是否 CollectionBase 具有固定大小。 (繼承來源 CollectionBase) |
| IList.IsReadOnly |
取得值,指出 CollectionBase 是否為唯讀。 (繼承來源 CollectionBase) |
| IList.Item[Int32] |
取得或設定位於指定索引處的專案。 (繼承來源 CollectionBase) |
| IList.Remove(Object) |
移除特定物件 CollectionBase首次出現的 。 (繼承來源 CollectionBase) |
擴充方法
| 名稱 | Description |
|---|---|
| AsParallel(IEnumerable) |
啟用查詢的平行處理。 |
| AsQueryable(IEnumerable) |
將 IEnumerable 轉換成 IQueryable。 |
| Cast<TResult>(IEnumerable) |
將 IEnumerable 的項目轉換成指定的型別。 |
| OfType<TResult>(IEnumerable) |
根據指定的型別篩選 IEnumerable 的專案。 |