How can i convert this VBNet code into C#? (ByteToImage is a User Defined Function use to convert Byte Array into Bitmap.
Dim Bytes() As Byte = CType(SQLreader("ImageList"), Byte())
picStudent.Image = jwImage.ByteToImage(Bytes)
I tried
byte[] Bytes = Convert.ToByte(SQLreader("ImageList")); // Error Here
picStudent.Image = jwImage.ByteToImage(Bytes);
but it generates an error saying: Cannot implicitly convert type 'byte' to 'byte[]'
What i am doing is basically converting an Image from database to byte array and displaying it on the picturebox.
The problem is you have an array of bytes (
byte[]in C# andByte()in VB.Net) but theConvert.ToBytecall just returns a simplebyte. To make this work you need to cast the return ofSQLreadertobyte[].There is no perfect analogous construct for
CTypein C# but a simple cast here should do the trick