【发布时间】:2011-07-01 09:30:13
【问题描述】:
C#中有什么方法可以清空字节数组?
Byte[] array = new Byte[64]; // contain all 0
// write some value into the array
// need empty array with all 0's
【问题讨论】:
C#中有什么方法可以清空字节数组?
Byte[] array = new Byte[64]; // contain all 0
// write some value into the array
// need empty array with all 0's
【问题讨论】:
Byte[] array = new Byte[64];
Array.Clear(array, 0, array.Length);
【讨论】:
Release 构建之外进行优化,对吧?例如:SecureZeroMemory 与 Win32 中的 ZeroMemory。
请使用 Array.Empty 方法
byte[] rawBytes = Array.Empty();
【讨论】:
我无休止地尝试使用 Array.Clear() 来清除程序中的一个大字节 []。它永远不会起作用。我不知道为什么。但我找到了解决方案:
数组 = 新字节[0];
【讨论】:
对 Array 使用“clear”方法。
Array.Clear(array , 0, array.Length);
【讨论】:
for (int i = 0; i < array.Length; i++)
array[i] = 0;
【讨论】: