Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert List<byte> to byte[] in C#?

Tags:

c#

list

byte

c#-2.0

Can I convert via a for loop?

Is there any better method to do it?

 for (int i = 0; i < myListByte.Count ;i++)
 {
     myArryByte[i] = myListByte[i];
 }
like image 718
Nano HE Avatar asked May 25 '11 03:05

Nano HE


2 Answers

myArryByte = myListByte.ToArray();
like image 98
Ry- Avatar answered Oct 13 '22 12:10

Ry-


List<byte> bytes = ...;

byte[] bArrary = bytes.ToArray();
like image 31
Bala R Avatar answered Oct 13 '22 11:10

Bala R