Convert byte to byte[]

Have you encountered error ever – “Can not implicitly convert byte to byte[]”? Here is the fix of it to convert byte to byte[]. This is quite basic error and error message is straightforward but many times beginners struggle with this. So here is sample code and demonstration of error and fix.

Getting above error when passing Byte value to Byte array .

Above issue can be solved :-

1.  DocImage = (byte[])(Convert.FromBase64String(rdr[1].ToString()))   

2.  DocImage = Convert.FromBase64String(rdr[1].ToString())

Hope this will help beginners in their issues.

Happy Coding! 🙂

Leave a Reply