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());
}
}
}
}
}
答案 0 :(得分:10)
设置
ff.Position = 0;
在阅读之前,否则你会在流的末尾开始阅读。