허당 레몬도리

출처 : https://stackoverflow.com/questions/34884854/convert-listint-to-byte

 

Convert list<int[]> to byte[]</int[]>

How to convert list<int[]> to byte[]? I could use this: byte[] bytes = lista.SelectMany(BitConverter.GetBytes).ToArray(); But it works only for list. If you have few ideas - m...</int[]>

stackoverflow.com

List -> byte[]

byte[] bytes = lista .SelectMany(x => x) .SelectMany(BitConverter.GetBytes) .ToArray();

 

byte[] -> List

List<int> list = bytes

.Select((item, index) => new {item, index})

.GroupBy(x => x.index/4)

.Select(g => g.Select(x => x.item).ToArray())

.Select(x => BitConverter.ToInt32(x, 0)) .ToList();

 

 

profile

허당 레몬도리

@LemonDory

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!