GCHandle.AddrOfPinnedObject Method

Definition

Pinned 句柄中检索对象数据的地址。Retrieves the address of object data in a Pinned handle.

public:
 IntPtr AddrOfPinnedObject();
[System.Security.SecurityCritical]
public IntPtr AddrOfPinnedObject ();
public IntPtr AddrOfPinnedObject ();
member this.AddrOfPinnedObject : unit -> nativeint
Public Function AddrOfPinnedObject () As IntPtr

Returns

IntPtr

固定的数据对象的地址。The address of the pinned data object.

Attributes

Exceptions

该句柄是 Pinned 以外的任何类型。The handle is any type other than Pinned.

Remarks

此方法用于获取指向对象数据的稳定指针。This method is used to get a stable pointer to the object data. 对于数组,此方法返回第一个元素的地址。For arrays, this method returns the address of the first element. 对于字符串,此方法返回第一个字符的地址。For strings, this method returns the address of the first character.

固定对象可防止垃圾回收器在内存中移动该对象,从而降低垃圾回收器的效率。Pinning an object prevents the garbage collector from moving it around in memory, thereby reducing the efficiency of the garbage collector.

Applies to

See also