Skip to content

Example of three ways to get an managed object pointer

Notifications You must be signed in to change notification settings

evan-choi/ObjectPointer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ObjectPointer

Example of three ways to get an managed object pointer

Intermediate Language

var person = new Person("Steal", 99);

// get managed pointer from object
IntPtr pointer = UnsafeObject.GetAddressFromIL(ref person);

// get object from managed pointer
var obj = UnsafeObject.GetObjectFromIL<Person>(pointer);

TypedReference

var person = new Person("Steal", 99);

// get TypedReference's pointer from object
IntPtr pointer = UnsafeObject.GetAddressFromTypedReference(ref person);

// get object from TypedReference's pointer
var obj = UnsafeObject.GetObjectFromTypedReference<Person>(pointer);

GCHandle

var person = new Person("Steal", 99);

// get GCHandle from object
IntPtr pointer = UnsafeObject.GetAddressFromGC(person);

// get object from GCHandle
var obj = UnsafeObject.GetObjectFromGC<Person>(pointer);

About

Example of three ways to get an managed object pointer

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages