I'd like to see how the C# array is laid in computer memory.
What I'd like to see is mainly two columns one with addresses second with array elements. Is it possible?
I'd like to start with 1D array but then I'd like to observe how multidimensional arrays are laid.
Question
How can I see it via VisualStudio ?
You can use the Visual Studio debugger to see the array layout. A simple example:
static void Main(string[] args) {
int[] arr = { 1, 2, 3 };
Console.ReadLine(); // Breakpoint here
}
Use Project + Properties, Build tab, Platform target = x86. Set a breakpoint on the indicated line, press F5, when it hits use Debug + Windows + Memory + Memory 1. Type arr
in the Address box. Right-click the window and select "4 byte Integer". Looks like this:
The first word is the "type handle", its value is random, just ignore it. You can no doubt guess the rest, you see the array Length and the array elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With