Why doesn't my hi world with streams show anything?

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace CSQuick { class Program { static void Main(string[] args) { using (var ff = new MemoryStream()) using (var f = new StreamWriter(ff)) { f.WriteLine("Stream hello world fail"); f.Flush(); using (TextReader ts = new StreamReader(ff)) { Console.WriteLine(ts.ReadToEnd()); } } } } } 
+4
source share
1 answer

Install
ff.Position = 0;
before reading, otherwise you will start reading at the end of the stream.

+10
source

All Articles