I\'d like to assign a reference to a member field. But I obviously do not understand this part of C# very well, because I failed :-) So, here\'s my code:
public
It sounds like what you're trying to do here is make a field a reference to another storage location. Essentially having a ref
field in the same way you have a ref
parameter. This is not possible in C#.
One of the main issues with doing this is that in order to be verifiable the CLR (and C#) must be able to prove the object containing the field won't live longer than the location it points to. This is typically impossible as objects live on the heap and a ref
can easily point into the stack. These two places have very different lifetime semantics (heap typically being longer than the stack) and hence a ref
between can't be proven to be valid.