Is there any method to empty an Byte array in C#?
Byte[] array = new Byte[64]; // contain all 0 // write some value into the array // need empty array with all 0's
There's no such thing as an "empty array" or an "empty element" in C. The array always holds a fixed pre-determined number of elements and each element always holds some value. The only way to introduce the concept of an "empty" element is to implement it yourself.
Technically you can't make an array empty. An array will have a fixed size that you can not change. If you want to reset the values in the array, either copy from another array with default values, or loop over the array and reset each value.
//there is no "empty" in C. There is always a fixed number of elements with some value.
The C and C++ languages have a null character (NUL), a null pointer (NULL), and a null statement (just a semicolon (;)). The C NUL is a single character that compares equal to 0. The C NULL is a special reserved pointer value that does not point to any valid data object.
Byte[] array = new Byte[64]; Array.Clear(array, 0, array.Length);
Kindly use Array.Empty method
byte[] rawBytes = Array.Empty();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With