Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
struct System.​Runtime.​InteropServices.​GCHandle
Assembly: System.Runtime
Implemented Interfaces
Provides a way to access a managed object from unmanaged memory.
Properties
public
bool
IsAllocated
Gets a value indicating whether the handle is allocated.
public
object
Target
Gets or sets the object this handle represents.
Methods
public
nint
AddrOfPinnedObject​()
Retrieves the address of object data in a <see cref="F:System.Runtime.InteropServices.GCHandleType.Pinned" /> handle.
Returns The address of the pinned data object.
public static
GCHandle
Alloc​(object value)
Allocates a <see cref="F:System.Runtime.InteropServices.GCHandleType.Normal" /> handle for the specified object.
Returns A new <see cref="T:System.Runtime.InteropServices.GCHandle" /> that protects the object from garbage collection. This <see cref="T:System.Runtime.InteropServices.GCHandle" /> must be released with <see cref="M:System.Runtime.InteropServices.GCHandle.Free" /> when it is no longer needed.
value
The object that uses the <see cref="T:System.Runtime.InteropServices.GCHandle" /> .
public static
GCHandle
Alloc​(object value,
GCHandleType type)
Allocates a handle of the specified type for the specified object.
Returns A new <see cref="T:System.Runtime.InteropServices.GCHandle" /> of the specified type. This <see cref="T:System.Runtime.InteropServices.GCHandle" /> must be released with <see cref="M:System.Runtime.InteropServices.GCHandle.Free" /> when it is no longer needed.
value
The object that uses the <see cref="T:System.Runtime.InteropServices.GCHandle" /> .
type
One of the <see cref="T:System.Runtime.InteropServices.GCHandleType" /> values, indicating the type of <see cref="T:System.Runtime.InteropServices.GCHandle" /> to create.
public
bool
Equals​(object o)
Determines whether the specified <see cref="T:System.Runtime.InteropServices.GCHandle" /> object is equal to the current <see cref="T:System.Runtime.InteropServices.GCHandle" /> object.
Returns <see langword="true" /> if the specified <see cref="T:System.Runtime.InteropServices.GCHandle" /> object is equal to the current <see cref="T:System.Runtime.InteropServices.GCHandle" /> object; otherwise, <see langword="false" /> .
o
The <see cref="T:System.Runtime.InteropServices.GCHandle" /> object to compare with the current <see cref="T:System.Runtime.InteropServices.GCHandle" /> object.
public
bool
Equals​(GCHandle other)
Indicates whether the current instance is equal to another instance of the same type.
Returns <see langword="true" /> if the current instance is equal to the other instance; otherwise, <see langword="false" /> .
other
An instance to compare with this instance.
public
void
Free​()
Releases a <see cref="T:System.Runtime.InteropServices.GCHandle" /> .
public static
GCHandle
FromIntPtr​(nint value)
Returns a new <see cref="T:System.Runtime.InteropServices.GCHandle" /> object created from a handle to a managed object.
Returns A new <see cref="T:System.Runtime.InteropServices.GCHandle" /> object that corresponds to the value parameter.
value
An <see cref="T:System.IntPtr" /> handle to a managed object to create a <see cref="T:System.Runtime.InteropServices.GCHandle" /> object from.
public
int
GetHashCode​()
Returns an identifier for the current <see cref="T:System.Runtime.InteropServices.GCHandle" /> object.
Returns An identifier for the current <see cref="T:System.Runtime.InteropServices.GCHandle" /> object.
public static
nint
ToIntPtr​(GCHandle value)
Returns the internal integer representation of a <see cref="T:System.Runtime.InteropServices.GCHandle" /> object.
Returns An <see cref="T:System.IntPtr" /> object that represents a <see cref="T:System.Runtime.InteropServices.GCHandle" /> object.
value
A <see cref="T:System.Runtime.InteropServices.GCHandle" /> object to retrieve an internal integer representation from.
public
string
ToString​()
Inherited from ValueType
Returns the fully qualified type name of this instance.
Returns The fully qualified type name.
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .