Home > other >  Cannot implicitly convert type 'byte[]' to 'byte?[]' in C#
Cannot implicitly convert type 'byte[]' to 'byte?[]' in C#

Time:10-14

My given code has an error of type conversion:

                byte?[] AibAttachment = null; 
                MemoryStream target = new MemoryStream();
                file.InputStream.CopyTo(target);
                AibAttachment = target.ToArray();
           

In above code AibAttachment = target.ToArray(); this line is throwing an error like "Cannot implicitly convert 'byte[]' to 'byte?[]'"

Please help me on this.

CodePudding user response:

Maybe you can do something like this:

AibAttachment = Array.ConvertAll(target.ToArray(), i => (byte?)i);
  • Related