CodeNamespaceImportCollection 类

定义

表示 CodeNamespaceImport 对象集合。Represents a collection of CodeNamespaceImport objects.

public ref class CodeNamespaceImportCollection : System::Collections::IList
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeNamespaceImportCollection : System.Collections.IList
type CodeNamespaceImportCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class CodeNamespaceImportCollection
Implements IList
继承
CodeNamespaceImportCollection
属性
实现

示例

下面的示例演示了CodeNamespaceImportCollection类的一些成员。The following example demonstrates some of the members of the CodeNamespaceImportCollection class. 该示例初始化类的新实例, 向其中添加CodeNamespaceImport对象, 并获取集合中对象的总数。The example initializes a new instance of the class, adds CodeNamespaceImport objects to it, and gets the total number of objects in the collection.

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

// Adds a CodeNamespaceImport to the collection.
collection->Add( gcnew CodeNamespaceImport( "System" ) );

// Adds an array of CodeNamespaceImport objects to the collection.
array<CodeNamespaceImport^>^ Imports = {
   gcnew CodeNamespaceImport( "System" ),
   gcnew CodeNamespaceImport( "System.Drawing" )};
collection->AddRange( Imports );

// Retrieves the count of the items in the collection.
int collectionCount = collection->Count;
// Creates an empty CodeNamespaceImportCollection.
CodeNamespaceImportCollection collection = 
    new CodeNamespaceImportCollection();            			

// Adds a CodeNamespaceImport to the collection.
collection.Add( new CodeNamespaceImport("System") );

// Adds an array of CodeNamespaceImport objects to the collection.
CodeNamespaceImport[] Imports = { 
        new CodeNamespaceImport("System"),
        new CodeNamespaceImport("System.Drawing") };
collection.AddRange( Imports );

// Retrieves the count of the items in the collection.
int collectionCount = collection.Count;
' Creates an empty CodeNamespaceImportCollection.
Dim collection As New CodeNamespaceImportCollection()

' Adds a CodeNamespaceImport to the collection.
collection.Add(New CodeNamespaceImport("System"))

' Adds an array of CodeNamespaceImport objects to the collection.
Dim [Imports] As CodeNamespaceImport() = _
    {New CodeNamespaceImport("System"), _
    New CodeNamespaceImport("System.Drawing")}
collection.AddRange([Imports])

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

注解

CodeNamespaceImportCollection 类提供一个简单的集合对象,该对象可用于存储一组 CodeNamespaceImport 对象。The CodeNamespaceImportCollection class provides a simple collection object that can be used to store a set of CodeNamespaceImport objects.

构造函数

CodeNamespaceImportCollection()

初始化 CodeNamespaceImportCollection 类的新实例。Initializes a new instance of the CodeNamespaceImportCollection class.

属性

Count

获取集合中命名空间的数目。Gets the number of namespaces in the collection.

Item[Int32]

获取或设置集合中指定索引处的 CodeNamespaceImport 对象。Gets or sets the CodeNamespaceImport object at the specified index in the collection.

方法

Add(CodeNamespaceImport)

CodeNamespaceImport 对象添加到集合中。Adds a CodeNamespaceImport object to the collection.

AddRange(CodeNamespaceImport[])

向集合添加一组 CodeNamespaceImport 对象。Adds a set of CodeNamespaceImport objects to the collection.

Clear()

清除成员集合。Clears the collection of members.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetEnumerator()

获取枚举集合成员的枚举数。Gets an enumerator that enumerates the collection members.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式界面实现

ICollection.CopyTo(Array, Int32)

从特定的 ICollection 索引开始,将 Array 的元素复制到一个 Array 中。Copies the elements of the ICollection to an Array, starting at a particular Array index.

ICollection.Count

获取 ICollection 中包含的元素数。Gets the number of elements contained in the ICollection.

ICollection.IsSynchronized

获取一个值,该值指示是否同步对 ICollection 的访问(线程安全)。Gets a value indicating whether access to the ICollection is synchronized (thread safe).

ICollection.SyncRoot

获取可用于同步对 ICollection 的访问的对象。Gets an object that can be used to synchronize access to the ICollection.

IEnumerable.GetEnumerator()

返回可循环访问集合的枚举器。Returns an enumerator that can iterate through a collection.

IList.Add(Object)

将对象添加到 IList 中。Adds an object to the IList.

IList.Clear()

IList 中移除所有项。Removes all items from the IList.

IList.Contains(Object)

确定 IList 是否包含特定值。Determines whether the IList contains a specific value.

IList.IndexOf(Object)

确定 IList 中特定项的索引。Determines the index of a specific item in the IList.

IList.Insert(Int32, Object)

IList 中的指定位置插入项。Inserts an item in the IList at the specified position.

IList.IsFixedSize

获取一个值,该值指示 IList 是否具有固定大小。Gets a value indicating whether the IList has a fixed size.

IList.IsReadOnly

获取一个值,该值指示 IList 是否为只读。Gets a value indicating whether the IList is read-only.

IList.Item[Int32]

获取或设置指定索引处的元素。Gets or sets the element at the specified index.

IList.Remove(Object)

IList 中移除特定对象的第一个匹配项。Removes the first occurrence of a specific object from the IList.

IList.RemoveAt(Int32)

移除 IList 的指定索引处的元素。Removes the element at the specified index of the IList.

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于

另请参阅