GCHandle.AddrOfPinnedObject GCHandle.AddrOfPinnedObject GCHandle.AddrOfPinnedObject GCHandle.AddrOfPinnedObject Method

定義

擷取 Pinned 控制代碼中物件資料的位址。Retrieves the address of object data in a Pinned handle.

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

傳回

已釘選資料物件的位址。The address of the pinned data object.

例外狀況

控制代碼是除了 Pinned 以外的任何型別。The handle is any type other than Pinned.

備註

這個方法是用來取得物件資料的穩定指標。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.

安全性

SecurityCriticalAttribute
需要完全信任立即呼叫者。requires full trust for the immediate caller. 部分信任或透明的程式碼無法使用這個成員。This member cannot be used by partially trusted or transparent code.

適用於

另請參閱