The shortest solution I know:
using(var memoryStream = new MemoryStream())
{
sourceStream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
More Related Contents:
- Ordered Unique Combinations [closed]
- Converting strings to arrays c#
- C# appointing distinct array elements randomly to another array
- How to generate an Array of Double Arrays in c#? [duplicate]
- Define if statement for property in C# [closed]
- How to convert UTF-8 byte[] to string
- How to access random item in list?
- How to convert byte array to string [duplicate]
- Easiest way to compare arrays in C#
- What is the Maximum Size that an Array can hold?
- How to store int[] array in application Settings
- How to resize multidimensional (2D) array in C#?
- Overhead of a .NET array?
- How to “flatten” or “index” 3D-array in 1D array?
- Testing equality of arrays in C#
- Copy Arrays to Array
- Correlation of two arrays in C#
- How to get a dimension (slice) from a multidimensional array
- Cannot deserialize the current JSON array (e.g. [1,2,3])
- Pick Random String From Array
- Random number generator in C# – unique values
- C# Permutation of an array of arraylists?
- Iterate through 2 dimensional array c#
- Why can’t I use the array initializer with an implicitly typed variable?
- convert string array to string
- How can I safely convert a byte array into a string and back? [duplicate]
- Why do arrays in .net only implement IEnumerable and not IEnumerable?
- Is it possible to extend arrays in C#?
- Is string actually an array of chars or does it just have an indexer?
- Array of an unknown length in C#