roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

Suggestion: string.Format without arguments

Open MSeifert04 opened this issue 6 years ago • 0 comments
trafficstars

Since the string.Format method allows for an arbitrary number of format arguments it also accepts 0. However in case one provides zero arguments this is likely a mistake:

string.Format("some-text here")

->

"some-text here"

The code is not really identical, so I'm not sure if it's generally useful.

For example string.Format removes double curly braces string.Format("{{0}}") == "{0}" and throws on any placeholder string.Format("{0}") == new FormatException, but in most cases a string.Format without arguments is likely an oversight or a downright bug.

MSeifert04 avatar Mar 12 '19 09:03 MSeifert04