IIterable<T> 介面

定義

公開反覆運算器,這個反覆運算器支援對指定型別的集合進行簡單反復專案。

。網此介面會顯示為System.Collections.Generic.IEnumerable < T >。 在任何Windows 執行階段類型已實作 IIterable < T > 的情況下,.NET 程式碼都可以改用IEnumerable < T >的 API。 C# 程式碼可以使用 foreach,Visual Basic 程式碼可以使用 For Each...接下來。 所有以IEnumerable < T >為基礎的 .NET 延伸模組方法,並包含在適用于 UWP 應用程式的 .NET 中,都可以存取包含System.Linq延伸模組 (,只要您包含命名空間) 即可。

public interface class IIterable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.FoundationContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(4205151722, 25108, 16919, 175, 218, 127, 70, 222, 88, 105, 179)]
template <typename T>
struct IIterable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]
[Windows.Foundation.Metadata.Guid(4205151722, 25108, 16919, 175, 218, 127, 70, 222, 88, 105, 179)]
public interface IEnumerable<T>
Public Interface IEnumerable(Of T)

類型參數

T
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.FoundationContract (已於 v1.0 引進)

備註

使用 .NET 進行程式設計時,此介面會隱藏,開發人員應該使用System.Collections.Generic.IEnumerable < T >介面。 由於投影的實作方式,因此仍支援GetEnumerator方法作為專案IEnumerable < T >實作之類型的直接可呼叫方法,但仍支援使用標準列舉語法列舉集合 (foreach) 。 編譯器會為您執行型別轉換,而且您不需要明確地轉換成 IEnumerable 。 如果您需要明確轉換,例如,如果您想要從類別呼叫GetEnumerator,請使用符合集合專案類型的轉換中的條件約束,轉換成IEnumerab < T >

C++/WinRT 擴充功能函式

注意

延伸模組函式存在於特定Windows 執行階段 API 的 C++/WinRT 投影類型上。 例如,winrt::Windows::Foundation::IAsyncAction 是 IAsyncAction的 C++/WinRT 投影類型。 擴充函式不是應用程式二進位介面的一部分, (實際Windows 執行階段類型的 ABI) 介面,因此它們不會列為Windows 執行階段 API 的成員。 但您可以從任何 C++/WinRT 專案內呼叫它們。 請參閱擴充 Windows 執行階段 API 的 C++/WinRT 函式

auto begin() const;

傳回反覆運算器給集合的第一個元素,以在 C++ 演算法中使用,例如範圍型 for 迴圈。

auto end() const;

將反覆運算器傳回至集合最後一個元素之後的反覆運算器,以用於 C++ 演算法,例如範圍型 for 迴圈。

方法

First()

傳回集合中專案的反覆運算器。

適用於

另請參閱