using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; //using指令 namespace _9._15._2_using语句的示例 { class Program { static void Main(string[] args) { //using语句 using (TextWriter tw = File.CreateText("Lincoln.txt")) { tw.WriteLine("Four scoreand seven years ago,..."); } //using语句 using (TextReader tr = File.OpenText("Lincoln.txt")) { string inputString; while ((inputString =tr.ReadLine()) != null) { Console.WriteLine(inputString); } } Console.ReadKey(); } } } 有以下几个问题请各位大神帮帮忙: 1、using (TextWriter tw = File.CreateText("Lincoln.txt"))这句话是什么意思?向Lincoln.txt文本文件中写入的内容是赋给了tw还是存到了其它地方?而tw是变量还是对象呢? 2、 tw.WriteLine("Four score and seven years ago,...");为何用tw调用WriteLine方法,而不用Console呢?他们两个有什么区别? |