Memoryblock in C#

Hi there, what is the best way to use something like a memoryblock in C#?

perhaps if we knew what languaage you had in mind?

Closures?

Sorry, if unclear. I know Memoryblocks from (surprise) Xojo and i would like to know, how to do approx the same in C#. What is the aquivalent for Memoryblocks (NSdata in Swift) in C#?

byte[] data = new byte [thesize];

?

A more direct equivalent is probably Memory or ReadOnlyMemory, although you can usually more safely use Span or ReadOnlySpan. I haven’t really needed a Memory yet, personally, but use spans on hot paths to good effect. And as JeffT suggested, a byte or char array is often a perfectly adequate buffer.