|
|
|
|
|
by matt_m
3692 days ago
|
|
C# works a little differently from C/C++ in that stack vs heap allocation is decided at the type level (using a 'struct' or 'class' keyword when defining the type). So you can't easily have one object have a reference to an interior Point in a Point[] array, since any Point instance variable will just be copied by-value and not be a reference. A Point in an array can be passed by reference into a function using the 'ref' keyword though, in which case I'd expect the GC to keep the whole array around until the function returns? (It seems hypothetically possible to optimize but kind of a niche case). If you need to, you can also actually use raw C pointers with an 'unsafe' keyword, that's outside of the GC though (useful for working with C libraries). |
|