Is there any method to empty an Byte array in C#?
有没有方法在C#中清空Byte数组?
Byte[] array = new Byte[64]; // contain all 0
// write some value into the array
// need empty array with all 0's
5 个解决方案
#1
67
Byte[] array = new Byte[64];
Array.Clear(array, 0, array.Length);
#3
2
Use the "clear" method on Array.
在Array上使用“clear”方法。
Array.Clear(array , 0, array.Length);
#4
1
for (int i = 0; i < array.Length; i++)
array[i] = 0;
#5
1
I tried endlessly to use Array.Clear() to clear a large byte[] that I have in my program. It would NEVER work. I do not know why. But I found a solution:
我无休止地尝试使用Array.Clear()来清除程序中的大字节[]。它永远不会奏效。我不知道为什么。但我找到了一个解决方案:
array = new byte[0];
array = new byte [0];
#1
67
Byte[] array = new Byte[64];
Array.Clear(array, 0, array.Length);
#2
#3
2
Use the "clear" method on Array.
在Array上使用“clear”方法。
Array.Clear(array , 0, array.Length);
#4
1
for (int i = 0; i < array.Length; i++)
array[i] = 0;
#5
1
I tried endlessly to use Array.Clear() to clear a large byte[] that I have in my program. It would NEVER work. I do not know why. But I found a solution:
我无休止地尝试使用Array.Clear()来清除程序中的大字节[]。它永远不会奏效。我不知道为什么。但我找到了一个解决方案:
array = new byte[0];
array = new byte [0];