3 ms·
C++ introduced the [[nodiscard]] attribute for this exact use case. A C# [NoDiscard] attribute would do the same thing with the help of a Roslyn analyzer I gues
by frabert 6y ago
C++ introduced the [[nodiscard]] attribute for this exact use case. A C# [NoDiscard] attribute would do the same thing with the help of a Roslyn analyzer I guess.
- goto11 6y agoC# already by default warns on discarded return values.
- algorithmsRcool 6y agoNo it does not, unless the discarded value is a Task in an async method. (or sometimes an IDisposable depending on what analyzers you have running)