I am supposed to do a project in C# to present how a list does work.
I'm thinking it's a good idea to show in a graphic interface like this:
-in "value" field: value of node
-in "next" field: physical address of next node
Is this possible?
I am supposed to do a project in C# to present how a list does work.
I'm thinking it's a good idea to show in a graphic interface like this:
-in "value" field: value of node
-in "next" field: physical address of next node
Is this possible?
Yes, with unsafe code (at least the virtual address, not the raw physical memory address, but that's just what you want).
Have a look at MSDN: How to: Obtain the Address of a Variable (C# Programming Guide) for details. It guides you through compiling the following example (it requires unsafe code to be enabled in the project properties or the /unsafe
switch) and what traps you could experience when getting the location of moveable variables, which require the fixed
keyword to stay at the same location, basically said.
int number;
int* p = &number; //address-of operator &