io/text-writer-reader/read-write-string/write-prog.cs - A StringWriter program similar to the StreamReader program shown earlier. | Lecture 10 - slide 22 : 40 Program 1 |
using System; using System.IO; using System.Text; public class TextSimpleTypes{ public static void Main(){ StringBuilder sb = new StringBuilder(); // A mutable string using(TextWriter tw = new StringWriter(sb)){ for (int i = 0; i < 5; i++){ tw.Write(5 * i); tw.WriteLine(); tw.Write(5.5 * i); tw.WriteLine(); tw.Write(5555M * i); tw.WriteLine(); tw.Write(5 * i == 6); tw.WriteLine();} } Console.WriteLine(sb); } }