Class StructRef<T>
Provides the ability to store a reference to an unmanaged struct without using pointers.
public class StructRef<T> where T : unmanaged
Type Parameters
TThe type of the unmanaged struct whose reference to store.
- Inheritance
-
StructRef<T>
- Inherited Members
- Extension Methods
Constructors
StructRef(ref T)
Initializes a new instance of the StructRef<T> class out of a reference to a struct instance.
public StructRef(ref T value)
Parameters
valueTThe struct instance whose reference to store initially.
Methods
GetReference()
Gets the stored struct instance reference.
public ref T GetReference()
Returns
- T
The stored reference to the struct instance.
Remarks
It is recommended to refer to the remarks of SetReference(ref T).
SetReference(ref T)
Sets the struct reference to a reference of another struct instance.
public void SetReference(ref T value)
Parameters
valueTThe struct instance whose reference to store.
Remarks
WARNING: The reference to the struct instance is not dynamically
updated. If the GC moves the reference, a risk for memory corruption is
induced.
One way to move the reference is if the unmanaged struct instance is a
class instance field, which class instance is moved by the GC.