如何删除在C#中的数组? [英] How to delete an array in c#?

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

问题描述

我很抱歉,如果这是一个明显的问题,但没有谷歌或搜索这里使我一个答案。

I'm sorry if this is an obvious question but neither Google or a search here led me to an answer.

有没有办法完全删除阵列?

Is there a way to remove an array entirely?

我要的相对的的 INT []数组=新INT [5]

推荐答案

假设你拨打:

 void Foo(){
     int[] a = new int[5];
 }

在C#有没有办法取消定义变量 A 。这意味着 A 将在定义,即使你设置 A 为null。
然而,在年底 A 将下降超出范围。这意味着没有code可以引用它,垃圾收集器将在下次运行时间,这可能不是很长一段时间释放内存为你的照顾。

In C# there is no way to undefine the variable a. That means a will be defined in Foo even if you set a to null. However, at the end of Foo a will fall out of scope. That means no code can reference it, and the garbage collector will take care of freeing the memory for you the next time it runs, which might not be for a long time.

这篇关于如何删除在C#中的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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