C#-using语句

时间:2020-08-11 21:28:55   收藏:0   阅读:66

using语句定义:

提供可确保正确使用 IDisposable 对象的方便语法。

eg:

string manyLines=@"This is line one
This is line two
Here is line three
The penultimate line is line four
This is the final, fifth line.";

using (var reader = new StringReader(manyLines))
{
    string? item;
    do {
        item = reader.ReadLine();
        Console.WriteLine(item);
    } while(item != null);
}

原文:https://www.cnblogs.com/Jaysonhome/p/13479551.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!