为什么第一段不能正常运行
StreamWriter sw = File.CreateText(path);
sw.WriteLine("Hello");
sw.WriteLine("And");
sw.WriteLine("Welcome");
这断为什么行
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("Hello");
sw.WriteLine("And");
sw.WriteLine("Welcome");
}
就是using在这里有什么用
StreamWriter sw = File.CreateText(path);
sw.WriteLine("Hello");
sw.WriteLine("And");
sw.WriteLine("Welcome");
这断为什么行
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("Hello");
sw.WriteLine("And");
sw.WriteLine("Welcome");
}
就是using在这里有什么用
是限定变量的生存期是在{}的范围内