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.
也许你可以做这样的事情:
AibAttachment = Array.ConvertAll(target.ToArray(), i => (byte?)i);
Another answer with Linq:
byte[] original = null; // something
byte?[] AibAttachment = original.Select(a => (byte?) a).ToArray();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.