C# 7 introduced discards as placeholders for values we do not have any use for in our code. They are write-only variables that allow us to explicitly inform the compiler or anyone reading our code to discard their content. They are particularly useful in scenarios where we receive a value but have no intention of using it.

4m read timeFrom code-maze.com
Post cover image
Table of contents
How a Discard Variable Differs From a Usual VariableWhy Do We Use a Discard Variable?Use Cases for Using a Discard Variable in C#Conclusion

Sort: