語言

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 覆寫該物件;否則,會建立新物件並加入集合。

適用於

另請參閱