using System; using System.IO;
namespace _06_10 { public class Class_06_10 { public static void Main(String[] args) { FileStream fs = File.Open("output.txt", FileMode.Create); BinaryWriter bw = new BinaryWriter(fs);
bool b = true; int i = 20000; double d = Math.PI; decimal de = (decimal)d * (decimal)d; string s = "你好";
bw.Write(b); bw.Write(i); bw.Write(d); bw.Write(de); bw.Write(s);
bw.Close();
fs = File.Open("output.txt", FileMode.Open); BinaryReader br = new BinaryReader(fs);
bool b1; int i1; double d1; decimal de1; string s1;
b1 = br.ReadBoolean(); i1 = br.ReadInt32(); d1 = br.ReadDouble(); de1 = br.ReadDecimal(); s1 = br.ReadString();
Console.WriteLine("b1 = {0}", b1); Console.WriteLine("i1 = {0}", i1); Console.WriteLine("d1 = {0}", d1); Console.WriteLine("de1 = {0}", de1); Console.WriteLine("s1 = {0}", s1);
br.Close(); fs.Close(); } } }