3 ms·
It's been pretty straightforward to do this since the start, since C# has had structs and pointers the whole time. It's gotten a lot easier now that there are s
by kevingadd 3y ago
It's been pretty straightforward to do this since the start, since C# has had structs and pointers the whole time. It's gotten a lot easier now that there are safe bounds-checked pointer abstractions (Span and Memory) so that you can work with raw memory anywhere you want without constantly having to manually do safety checks to avoid heap corruption. 'where T : unmanaged' means you can finally write generics around pointers too.
now that you can return refs instead of just passing them around, that's also really nice for cases where you want to pass around an interior pointer into some sort of data structure - you can use refs whether a value is allocated via the GC or malloc or stackalloc.