如何快速将数组清零? [英] How to quickly zero out an array?
本文介绍了如何快速将数组清零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在 for 循环中执行此操作,并且我知道在 C 中有 ZeroMemory API,但是在 C# 中似乎不可用.也不存在与 Java 相当的 Array.fill.我只是想知道是否有更简单/更快的方法?
I am currently doing it in a for loop, and I know in C there is the ZeroMemory API, however that doesn't seem to be available in C#. Nor does the somewhat equivalent Array.fill from Java exist either. I am just wondering if there is an easier/faster way?
推荐答案
尝试 Array.Clear():
设置数组中的元素范围为零、false
或空
(在 Visual Basic 中没有),取决于关于元素类型.
Sets a range of elements in the Array to zero, to
false
, or tonull
(Nothing in Visual Basic), depending on the element type.
这篇关于如何快速将数组清零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文