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/06/25 06:24:24
![C# using啥意思.public static void Main(String[] args){using (StreamWriter w = File.AppendText(](/uploads/image/z/9656296-16-6.jpg?t=C%23+using%E5%95%A5%E6%84%8F%E6%80%9D.public+static+void+Main%28String%5B%5D+args%29%7Busing+%28StreamWriter+w+%3D+File.AppendText%28%22log.txt%22%29%29%7BLog+%28%22Test1%22%2Cw%29%3BLog+%28%22Test2%22%2Cw%29%3B%2F%2F+Close+the+writer+and+underlying+file.w.Close%28%29%3B%7D%2F%2F+Open+and+read+the+file.using+%28StreamReader+r+%3D+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.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是指导入命名空间.