| ▲ | fweimer 21 hours ago | |
I thought that C# does not have escaping interior pointers, unlike Go. Last time I looked at the CLR, I couldn't find support for interior pointers. | ||
| ▲ | debugnik 18 hours ago | parent | next [-] | |
Only so-called "ref" (and "out") variables/returns/fields can point to the inside of an object. These follow some borrow-checking rules so they can also point into stack variables, thus only ref-like types like Span<T> can hold ref and ref-like fields, and these are always rooted in the stack. But refs into the inside of a class type can escape the function, because they can keep the object alive. | ||
| ▲ | afdbcreid 19 hours ago | parent | prev [-] | |
It does but only on the stack, known as `ref struct`. E.g. `Span<T>` is an interior pointer, and this is extremely common in modern C#. | ||