StringWriter/Reader
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
class Program {
static void Main(string[] args) {
StringWriter strWriter = new StringWriter();
strWriter.WriteLine("Don't forget Mother's Day this year...");
strWriter.Close();
Console.WriteLine(strWriter);
StringBuilder sb = strWriter.GetStringBuilder();
sb.Insert(0, "Hey!! ");
Console.WriteLine("-> {0}", sb.ToString());
sb.Remove(0, "Hey!! ".Length);
Console.WriteLine("-> {0}", sb.ToString());
StringReader strReader = new StringReader(strWriter.ToString());
string input = null;
while ((input = strReader.ReadLine()) != null) {
Console.WriteLine(input);
}
strReader.Close();
}
}
Related examples in the same category