怎么看一个C#数组如何在内存布局? [英] how to see how a C# array is laid in memory?

查看:130
本文介绍了怎么看一个C#数组如何在内存布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想看到C#数组如何在计算机内存中奠定。

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.

我怎么能看到它的VisualStudio通过?

How can I see it via VisualStudio ?

推荐答案

您可以使用Visual Studio调试器看到阵列布局。一个简单的例子:

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
    }

使用项目+属性,生成标签,目标平台= 86。在指定的行,preSS F5,当它击中在地址框中使用调试+的Windows +内存+内存1.键入改编设置一个断点。右键单击该窗口中,选择4字节的整数。看起来是这样的:

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.

这篇关于怎么看一个C#数组如何在内存布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆