Can I get the physical address of a variable or object in C #?
1 answer
Yes, with unsafe code (at least a virtual address, not a physical physical memory address, but that's exactly what you want).
Have a look at MSDN: How to Get the Address of a Variable (C # Programming Guide) . It will help you compile the following example (requires /unsafe
unsafe code to be included in project properties or switch ) and what pitfalls might occur when getting the location of movable variables that require the keyword fixed
in the same place basically said.
int number;
int* p = &number; //address-of operator &
+3
source to share