Reputation: 8033
Perhaps the answer is "depends on which ctor was used"?
Span<T>(Void*, Int32)
: I'm sure it doesn't (can't) pin... How about Span<T>(T[])
and its cousin Span<T>(T[], Int32, Int32)
?
By "pinning" I mean How can I pin an array of byte?
Upvotes: 1
Views: 373
Reputation: 283793
No, Span<T>
doesn't pin anything. If it did, what would be the point of Span<T>.GetPinnableReference()
?
Note that the documentation for GetPinnableReference()
says
Applications should not directly call
GetPinnableReference
. Instead, callers should use their language's normal pinning syntax, such as C#'sfixed
statement.
From that we can again infer than an object is not pinned by Span<T>
alone, but is pinned if fixed
is used.
Upvotes: 2