ContextStack.Item[] 屬性

定義

取得或設定堆疊上的物件在指定層級。

多載

名稱 Description
Item[Int32]

在指定層級取得堆疊上的物件。

Item[Type]

取得堆疊中第一個繼承或實作指定型別的物件。

Item[Int32]

在指定層級取得堆疊上的物件。

public:
 property System::Object ^ default[int] { System::Object ^ get(int level); };
public object this[int level] { get; }
member this.Item(int) : obj
Default Public ReadOnly Property Item(level As Integer) As Object

參數

level
Int32

堆疊上要取回物件的等級。 0 級是堆疊的頂端,1 級是下層,依此類推。 這個等級必須是0或更高。 若 level 大於堆疊上的 level 數,則返回 null

屬性值

堆疊中指定層級的物件,或 null 若該層級不存在物件,則為該物件。

例外狀況

level 小於0。

適用於

Item[Type]

取得堆疊中第一個繼承或實作指定型別的物件。

public:
 property System::Object ^ default[Type ^] { System::Object ^ get(Type ^ type); };
public object this[Type type] { get; }
member this.Item(Type) : obj
Default Public ReadOnly Property Item(type As Type) As Object

參數

type
Type

一個從上下文堆疊中擷取的型別。

屬性值

堆疊中第一個繼承或實作指定型別的物件,或 null 若堆疊中沒有物件實作該型別,則為該物件。

例外狀況

typenull

備註

在堆疊的每一層都會進行檢查,尋找實作或繼承 type的物件。 若找到匹配,則會退回。

適用於