我在 C# 中使用一个数组,如下所示:
class abc
{
xyz x = new xyz(); // some other class
public double [] arr = new double [100]; // Allocated 400 bytes
// for this array.
// 100 is imaginary size
// shown here for simplicity.
// Actual size will depend on input.
private void something()
{
x.funA(arr);
}
}
在abc
上面的类中,数组消耗 400 个字节。现在,我在某个函数中将该数组作为参数传递给 class xyz
。
我的问题是是否会在 class 中分配新的 400 字节xyz
。400 字节并不是什么大问题,但在我的程序中,我传递了一个占用 1 MB 的数组。