Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
5 votes
1 answer
1k views

Why is the Pinnable<T> class in C# 7.2 defined the way it is?

I'm aware that Pinnable<T> is an internal class used by the methods in the new Unsafe class, and it's not meant to be used anywhere else other than in that class. This question is not about ...
Sergio0694's user avatar
  • 4,527
0 votes
1 answer
431 views

IL method to pin a ref T value as void* (to work on Span<T> from parallel code)

Before the actual question, a small disclaimer: This is a related/follow up question to this one, but since here I'm talking about a more general issue (how to pin a ref T variable to be able to ...
Sergio0694's user avatar
  • 4,527
9 votes
1 answer
2k views

How to pin a generic Span<T> instance to work on it with Parallel.For?

I'm rewriting some of my extension methods using the new Span<T> type and I'm having trouble finding a way to properly pin a generic instance to be able to use parallel code to work on it. As ...
Sergio0694's user avatar
  • 4,527
7 votes
2 answers
993 views

Slicing a Span<T> row from a 2D matrix - not sure why this works

I've been looking for a way to extract slices from a 2D matrix without having to actually reallocate-copy the contents, and public static Span<float> Slice([NotNull] this float[,] m, int row) {...
Sergio0694's user avatar
  • 4,527