Home > Code Analysis > Code Issues – Format item index too large

Code Issues – Format item index too large

October 18th, 2012

Cause:

In the String.Format call you can specify any number of arguments and the corresponding format items, where those argument values will be inlined. When the corresponding argument in the call is absent, the FormatException will be thrown (Index (zero based) must be greater than or equal to zero and less than the size of the argument list). The compiler does not validate the format items, so this may lead to errors in your application. This code issue allows you to avoid such errors by highlighting format items with an incorrect index.

Sample:

CodeRush Format Item Index Too Large Sample

How to Fix:

  • Remove or correct the index of the format item:

CodeRush Format Item Index Too Large Fix

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Oct/18/2012
ID: C202

Similar Posts: