Share via


IVector<T>.GetMany(UInt32, T[]) 方法

定义

从给定索引处开始的向量中检索多个项。

C++/WinRT C++/WinRT 语言投影的正确语法为 uint32_t GetMany(uint32_t startIndex, winrt::array_view<T> items);

public:
 unsigned int GetMany(unsigned int startIndex, Platform::Array <T> ^ items);
uint32_t GetMany(uint32_t const& startIndex, winrt::array_view <T> & items);
public uint GetMany(uint startIndex, T[] items);
Public Function GetMany (startIndex As UInteger, items As T()) As UInteger

参数

startIndex
UInt32

unsigned int

uint32_t

从零开始的索引。

items
T[]

一个数组,用于接收从向量复制的项。

C++/WinRT 接收从向量复制的项的 winrt::array_view

返回

UInt32

unsigned int

uint32_t

检索到的项数。 如果到达矢量的末尾,此值可以小于 的大小。

注解

使用 .NET 编程时,此接口是隐藏的。 请改用 IList 接口。

C++/WinRT 除了传递 winrt::array_view<T> 外,还可以传递任何可转换为 winrt::array_view<T> 的对象,如以下示例。

  • C++ std::array<T、N>
  • T 的 C 样式数组
  • C++ std::vector<T>
  • { pointer, length },其中 pointer 是指向 T 对象的缓冲区的指针, length 是缓冲区中的条目数
  • { first, last },其中 firstlast 表示 T 对象的范围 [first, last)

如果起始索引大于集合的大小,视图将引发异常。

C++/WinRT 如果起始索引大于集合的大小,视图将引发 hresult_out_of_bounds 异常。

C++/CX 如果起始索引大于集合的大小,视图将引发 OutOfBoundsException 异常。

适用于