语言

NamespaceCollection.Item[Int32] 属性

定义

获取或设置 NamespaceInfo 集合中指定索引处的对象。

public:
 property System::Web::Configuration::NamespaceInfo ^ default[int] { System::Web::Configuration::NamespaceInfo ^ get(int index); void set(int index, System::Web::Configuration::NamespaceInfo ^ value); };
public System.Web.Configuration.NamespaceInfo this[int index] { get; set; }
member this.Item(int) : System.Web.Configuration.NamespaceInfo with get, set
Default Public Property Item(index As Integer) As NamespaceInfo

参数

index
Int32

集合中对象的索引 NamespaceInfo 。

属性值

NamespaceInfo 指定索引处的对象,或者 null 该索引处没有对象。

示例

下面的代码示例演示如何使用该 Item[] 属性。 该代码示例是 PagesSection 类中的一个较大示例的一部分。

// Get all current Namespaces in the collection.
for (int i = 0; i < pagesSection.Namespaces.Count; i++)
{
  Console.WriteLine(
      "Namespaces {0}: '{1}'", i,
      pagesSection.Namespaces[i].Namespace);
}
' Get all current Namespaces in the collection.
Dim i As Int16
For i = 0 To pagesSection.Namespaces.Count - 1
  Console.WriteLine( _
   "Namespaces {0}: '{1}'", i, _
   pagesSection.Namespaces(i).Namespace)
Next

注解

如果对象已存在于指定的索引处,则此属性将覆盖 NamespaceInfo 该对象;否则,将创建一个新对象并将其添加到集合中。

适用于

另请参阅