The shortest solution I know:
using(var memoryStream = new MemoryStream()) { sourceStream.CopyTo(memoryStream); return memoryStream.ToArray(); }
2.1m questions
2.1m answers
60 comments
57.0k users