Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Ch 01. Arrays and Strings/Q1_03_URLify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private void ReplaceSpaces(char[] input, int length)
var space = new[] { '0', '2', '%' };
var spaceCount = Count_the_number_of_spaces(input);
// calculate new string size
var index = length + spaceCount * 2;
var index = length + spaceCount * 2 -1;
void SetCharsAndMoveIndex(params char[] chars)
{
foreach (var c in chars)
Expand All @@ -37,7 +37,7 @@ void SetCharsAndMoveIndex(params char[] chars)
public override void Run()
{
const string input = "abc d e f";
var characterArray = new char[input.Length + 3 * 2 + 1];
var characterArray = new char[input.Length + 3 * 2];

for (var i = 0; i < input.Length; i++)
{
Expand All @@ -48,4 +48,4 @@ public override void Run()
Console.WriteLine("{0} -> {1}", input, new string(characterArray));
}
}
}
}