标签:writer game evel str pre class layer play pen
//将对象写入文件中 Game game = new Game(); game.Level = 2; game.Player = "Tom"; FileStream fs = new FileStream(@"game.bak",FileMode.OpenOrCreate,FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(game.Player); sw.WriteLine(game.Level); sw.Flush(); sw.Close(); //将文件重构成对象 Game game = new Game(); FileStream fs = new FileStream(@"game.bak", FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); game.Player = sr.ReadLine(); game.Leveal = sr.ReadLine(); sr.Close();
标签:writer game evel str pre class layer play pen
原文地址:http://www.cnblogs.com/zwnet/p/6135595.html