Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    Writing values of simple types and objects of our own classes.Lecture 10 - slide 13 : 40
Program 2
using System;
using System.IO;

public class TextSimpleTypes{
  
  public static void Main(){
 
    using(TextWriter tw = new StreamWriter("simple-types.txt")){   
      tw.Write(5);  tw.WriteLine();                                
      tw.Write(5.5);  tw.WriteLine();                              
      tw.Write(5555M); tw.WriteLine();
      tw.Write(5==6); tw.WriteLine();
    }

    using(TextWriter twnst = new StreamWriter("non-simple-types.txt")){   
      twnst.Write(new Point(1,2)); twnst.WriteLine();                     
      twnst.Write(new Die(6)); twnst.WriteLine();                         
    }

  }
}
 
 
 
 
 
 
 
Make a StreamWriter with default
encoding, and write a number of simple
values to the underlying stream.
 
 
 
 
Similary, make a StreamWriter
a write a Point and a Die (via
ToString) to the underlying stream.