Answer the question
In order to leave comments, you need to log in
How to convert int array to byte array?
array int[]? Whether it is possible to transform in one action, instead of each element to read. An array is just a region in memory. Changing the type, I don’t change anything, the same 4 bytes remain in the same place.
Answer the question
In order to leave comments, you need to log in
Maybe something like.
var array = new[] {1, 2, 3, 4};
var span = new Span<int>(array);
var bytes = MemoryMarshal.AsBytes(span);
var byteArray = bytes.ToArray(); //тут будет копирование.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question