C# using啥意思.public static void Main(String[] args){using (StreamWriter w = File.AppendText("log.txt")){Log ("Test1",w);Log ("Test2",w);// Close the writer and underlying file.w.Close();}// Open and read the file.using (StreamReader r = File.Ope
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/20 06:01:13
C# using啥意思.public static void Main(String[] args){using (StreamWriter w = File.AppendText("log.txt")){Log ("Test1",w);Log ("Test2",w);// Close the writer and underlying file.w.Close();}// Open and read the file.using (StreamReader r = File.Ope
C# using啥意思.
public static void Main(String[] args)
{
using (StreamWriter w = File.AppendText("log.txt"))
{
Log ("Test1",w);
Log ("Test2",w);
// Close the writer and underlying file.
w.Close();
}
// Open and read the file.
using (StreamReader r = File.OpenText("log.txt"))
{
DumpLog (r);
}
}
这里的using啥意思?我只知道using system写在类最上方那种的~
C# using啥意思.public static void Main(String[] args){using (StreamWriter w = File.AppendText("log.txt")){Log ("Test1",w);Log ("Test2",w);// Close the writer and underlying file.w.Close();}// Open and read the file.using (StreamReader r = File.Ope
你注意到using的圆括号和花括号了嘛?
意思是在圆括号里面的实例,只能在花括号中存活..
出了花括号.GC垃圾回收机制将自动回收这个实例.
在类最上面的using是指导入命名空间.