日期:2014-05-18 浏览次数:20913 次
StreamReader freader = File.OpenText("input.txt"); StreamWriter fwriter = File.CreateText("output.txt"); string text_line; while ((text_line = freader.ReadLine()) != null) { if (text_line.Length == 0) { fwriter.WriteLine(text_line); } } fwriter.Close; //这里出错 freader.Close; //这里出错
StreamReader freader = File.OpenText("input.txt"); StreamWriter fwriter = File.CreateText("output.txt"); string text_line; while ((text_line = freader.ReadLine()) != null) { if (text_line.Length == 0) { fwriter.WriteLine(text_line); } } //C#里面, .后面不带括号的是属性 带括号的是方法..这样说 你能理解吗? fwriter.Close(); freader.Close();
------解决方案--------------------
用using语句吧。
------解决方案--------------------
呵呵,我也老是忘记括号,不过一般系统给我指出了我就马上醒悟啦……
方法后面都是要()滴~~不管你有没有参数……