ReSharper 2025.2 Help

代码检查:未访问的局部变量仅用于丢弃 'out' 参数值

此检查报告仅用于保存 out 参数值且未在方法中其他地方使用的变量。

从 C# 7.0 开始,对于 out 参数,若您不关心,可以用 discard_ 替换参数,以明确表示您有意不使用 out 参数值。

class Testing { void Foo(out string str) { str = "Hello world"; } void Test() { string test; Foo(out test); } }
class Testing { void Foo(out string str) { str = "Hello world"; } void Test() { Foo(out _); } }
最后修改日期: 2025年 9月 27日