Code inspection: Use format specifier in format strings
This inspection suggests specifying the string formatting within the format placeholder of the String.Format()
, rather than in an explicit ToString()
call on the argument.
In the example below, moving the format specifier into the placeholder improves the conciseness and readability of the code.
public void Test(int i)
{
var str = string.Format("Result: {0}", i.ToString("N"));
}
public void Test(int i)
{
var str = string.Format("Result: {0:N}", i);
}
Last modified: 06 June 2024