Back to Devexpress

CRR0016 - Method call's return value is ignored

coderushforroslyn-118124-static-code-analysis-analyzers-library-crr0016-method-calls-return-value-is-ignored.md

latest996 B
Original Source

CRR0016 - Method call's return value is ignored

  • Feb 28, 2025

This analyzer detects calls to non-void methods where the return value is not considered. Normally, if a method returns data, you should check or save the output. Consider the following example.

csharp
string s = "(10.2, 381.8)";
s.Replace(",", ";"); // CRR0016
vb
Dim s As String = "(10.2, 381.8)"
s.Replace(",", ";") ' CRR0016

In this code, the programmer expects that the Replace method modifies the source string. Since it is not so, the statement is useless and should be changed as follows.

csharp
string s = "(10.2, 381.8)";
s = s.Replace(",", ";");
vb
Dim s As String = "(10.2, 381.8)"
s = s.Replace(",", ";")

See Also

Suppress Analyzers