JetBrains Rider 2024.1 Help

Code inspection: Non-accessed local variable only used to discard the 'out' parameter value

This inspection reports variables that are only being used to hold the out parameter value and are not used anywhere else in the method.

Starting with C# 7.0, for out parameters that you do not care about, you can replace the argument with the discard _ to make it clear that you are intentionally not using the out parameter value.

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 _); } }
Last modified: 04 June 2024