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());
}
}
}
}
}
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace CSQuick { class
Share
Set
ff.Position = 0;before reading, otherwise you start reading at the end of the stream.