Send comments on this topic. |
|
Glossary Item Box
Cause
Rule Description
For example, the following code would violate this rule, since the second parameter spans across multiple lines:
return JoinStrings(
"John",
"Smith" +
" Doe");
When parameters other than the first parameter span across multiple lines, it can be difficult to tell how many parameters are passed to the method. In general, the code becomes difficult to read.
To fix the example above, ensure that the parameters after the first parameter do not span across multiple lines. If this will cause a parameter to be excessively long, store the value of the parameter within a temporary variable. For example:
string last = "Smith" +
" Doe";
return JoinStrings(
"John",
last);
In some cases, this will allow the method to be written even more concisely, such as:
return JoinStrings("John", last);
How to Fix Violations
© Microsoft Corporation. All Rights Reserved.