MemoryMarshal.CreateSpan<T>(T, Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在一般受控物件上建立新的範圍。
public:
generic <typename T>
static Span<T> CreateSpan(T % reference, int length);
public static Span<T> CreateSpan<T> (ref T reference, int length);
public static Span<T> CreateSpan<T> (scoped ref T reference, int length);
static member CreateSpan : 'T * int -> Span<'T>
Public Shared Function CreateSpan(Of T) (ByRef reference As T, length As Integer) As Span(Of T)
類型參數
- T
資料項目的類型。
參數
- reference
- T
資料的參考。
- length
- Int32
reference
包含的 T
元素數目。
傳回
範圍。
備註
如果 Managed 物件的一部分代表固定陣列,這個方法會很有用。
警告
這個方法應該謹慎使用。 因為未檢查引數, length
所以很危險。 即使 ref
被標注為 scoped
,它仍會儲存到傳回範圍,而且傳回範圍的存留期不會經過驗證以取得安全性,即使透過範圍感知語言也一樣。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應