Back to Devexpress

CRR0007 - String format item/argument mismatch

coderushforroslyn-118105-static-code-analysis-analyzers-library-crr0007-string-format-item-argument-mismatch.md

latest882 B
Original Source

CRR0007 - String format item/argument mismatch

  • Feb 28, 2025

This analyzer detects formatted strings whose format does not correspond to arguments.

csharp
string s = string.Format("{0} {2}", arg1, arg2); // CRR0007
vb
Dim s As String = String.Format("{0} {2}", arg1, arg2) ' CRR0007

In the example above, you can fix the mistake by adding the third parameter, which will be referred by the “ {2} “ placeholder, or changing the code as follows.

csharp
string s = string.Format("{0} {1}", arg1, arg2);
vb
Dim s As String = String.Format("{0} {1}", arg1, arg2)

See Also

Suppress Analyzers