// convert string to stream MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter( stream ); writer.Write( test ); writer.Flush(); // convert stream to string stream.Position = 0; StreamReader reader = new StreamReader( stream ); string text = reader.ReadToEnd(); public static Task<string> ReadStream(Stream stream) { stream.Position = 0; using var reader = new StreamReader(stream); return reader.ReadToEndAsync(); }
511600cookie-checkC# Simple Stream Conversion