C#+无unsafe的非托管大数组(large unmanaged array in c# without 'unsafe' keyword) +BIT祝威+悄悄在此留下版了个权的信息说: C#申请一个大数组(Use a large array in C#) 在C#里,有时候我需要能够申请一个很大的数组.使用之.然后立即释放其占用的内存. Sometimes I need to allocate a large array, use it and then release its memory
今天写代码时发现了如下问题: public class Test { public static void main(String[] args) { int[] arr= new int[5]; for (int a : arr) { a=1; } System.out.println(Arrays.toString(arr)); } } [, , , , ] 可以看出,使用foreach方法没办法给数组赋值. 实际上,foreach语句 for (int a : arr) { a=1; }