Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot implicitly convert 'byte[]' to 'byte'

Tags:

c#

.net

My given code has an error of type conversion

 int imglength = FileUpload2.PostedFile.ContentLength;
 byte imgarray=new byte[imglength];
like image 218
Raghu Avatar asked Dec 08 '22 10:12

Raghu


2 Answers

You're trying to assign an array of bytes (byte[]) to a single byte, hence the error.

Try the following code:

byte[] imgarray = new byte[imglength];
like image 82
Tim Avatar answered Dec 11 '22 07:12

Tim


you can not assign a byte array to byte

try this

byte[] bytearray = new byte[imglength];
like image 42
Vinay Pratap Singh Bhadauria Avatar answered Dec 11 '22 08:12

Vinay Pratap Singh Bhadauria