放入 using 语句时,丢弃变量 _ 会调用 Dispose() 吗?

Will the discard variable _ call Dispose() when put in a using statement?

如果 ZipArchive 文件不存在,我想创建它。然后我想在更新它之前打开它来阅读它的信息。那么丢弃变量 _ 的这种有效使用是否按预期工作?

using (_ = ZipFile.Open(filename, ZipArchiveMode.Update)) { }

有一个类似的问题,他说_在这样使用时不调用dispose:

var a = TestMethod(out _.Dispose());

它被调用 - 检查反编译的 code on sharplab (or write a simple test snippet)。但是如果你不需要这个变量,你可以完全跳过丢弃并写:

using (ZipFile.Open(filename, ZipArchiveMode.Update)) 
{ 

}

随着 same effect.