小编arz*_*arz的帖子

C# 中 StreamReader 何时变为 null?

我看到了这个链接:

https://learn.microsoft.com/en-us/dotnet/api/system.idisposable?view=net-6.0

代码部分是:

if (!File.Exists(filename))
    throw new FileNotFoundException("The file does not exist.");

this.filename = filename;
string txt = String.Empty;
StreamReader sr = null;
try
{
    sr = new StreamReader(filename);
    txt = sr.ReadToEnd();
}
finally
{
    if (sr != null) sr.Dispose();
}
Run Code Online (Sandbox Code Playgroud)

StreamReader什么时候变成null?

c# streamreader

0
推荐指数
2
解决办法
169
查看次数

标签 统计

c# ×1

streamreader ×1