JetBrains Rider 2025.2 Help

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

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

从 C# 7.0 开始,对于 参数,若您不关心,可以用 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月 26日