Creating a byte array from a stream

后端 未结 16 2993
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-21 23:22

What is the prefered method for creating a byte array from an input stream?

Here is my current solution with .NET 3.5.

Stream s;
byte[] b;

using (         


        
16条回答
  •  無奈伤痛
    2020-11-21 23:37

    In namespace RestSharp.Extensions there is method ReadAsBytes. Inside this method is used MemoryStream and there is the same code like in some examples on this page but when you are using RestSharp this is easiest way.

    using RestSharp.Extensions;
    var byteArray = inputStream.ReadAsBytes();
    

提交回复
热议问题