Skip to content

Commit

Permalink
do not use link to slice array (#1472)
Browse files Browse the repository at this point in the history
  • Loading branch information
hazzik authored Feb 29, 2024
1 parent 4f92bb6 commit 0b03632
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,10 @@ string HumanizeDisplayStrings(IEnumerable<string?> strings, string separator)
return itemsArray[0];
}

var itemsBeforeLast = itemsArray.Take(count - 1);
var lastItem = itemsArray
.Skip(count - 1)
.First();

return string.Format(GetConjunctionFormatString(count),
string.Join(", ", itemsBeforeLast),
string.Join(", ", itemsArray, 0, itemsArray.Length - 1),
separator,
lastItem);
itemsArray[^1]);
}

protected virtual string GetConjunctionFormatString(int itemCount) => "{0} {1} {2}";
Expand Down

0 comments on commit 0b03632

Please sign in to comment.