经常用到,但老记不住,备忘一下
using (var ms = new MemoryStream()) { var sw = new StreamWriter(ms); sw.WriteLine("Hello World"); sw.Flush(); ms.Position = 0; var sr = new StreamReader(ms); var myStr = sr.ReadToEnd(); Console.WriteLine(myStr); }
经常用到,但老记不住,备忘一下
using (var ms = new MemoryStream()) { var sw = new StreamWriter(ms); sw.WriteLine("Hello World"); sw.Flush(); ms.Position = 0; var sr = new StreamReader(ms); var myStr = sr.ReadToEnd(); Console.WriteLine(myStr); }