Reputation: 430
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.
Upvotes: 0
Views: 1201
Reputation: 5519
Another answer with Linq:
byte[] original = null; // something
byte?[] AibAttachment = original.Select(a => (byte?) a).ToArray();
Upvotes: 2
Reputation: 91
Maybe you can do something like this:
AibAttachment = Array.ConvertAll(target.ToArray(), i => (byte?)i);
Upvotes: 4