Skip to content

Commit 0822213

Browse files
committed
Add commas for thousand seperator for numeric output and make sure text counter output has no line wraps
1 parent d0bd470 commit 0822213

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

text-counter-blazor/Components/Pages/TextCounter.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
{
1717
textOutput = "";
1818
string Value = textContent;
19-
textOutput += $"Characters: {Value.Length}\n";//number of characters
20-
textOutput += $"Words: {Value.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Length}\n";//number of words
21-
textOutput += $"Lines: {Value.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length}\n";//number of lines
19+
textOutput += $"Characters: {Value.Length.ToString("N0")}\n";//number of characters
20+
textOutput += $"Words: {Value.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Length.ToString("N0")}\n";//number of words
21+
textOutput += $"Lines: {Value.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length.ToString("N0")}\n";//number of lines
2222
}
2323
}

text-counter-console-app/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
}
1010
textContent += textInput + '\n';//add text content from entered text input for each line
1111
}
12-
Console.WriteLine($"Characters: {textContent.Length}");//number of characters
13-
Console.WriteLine($"Words: {textContent.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Length}");//number of words
14-
Console.WriteLine($"Lines: {textContent.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length}");//number of lines
12+
Console.WriteLine($"Characters: {textContent.Length.ToString("N0")}");//number of characters
13+
Console.WriteLine($"Words: {textContent.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Length.ToString("N0")}");//number of words
14+
Console.WriteLine($"Lines: {textContent.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length.ToString("N0")}");//number of lines

text-counter-razor/Pages/TextCounter.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
<textarea id="textContent" name="textContent" rows="10" cols="80" asp-for="textContent"></textarea><br />
99
<button>Update Text Counter Output</button><br />
1010
</form>
11-
<div id="textOutput">Characters: @Model.characters<br />Words: @Model.words<br />Lines: @Model.lines
11+
<div id="textOutput">Characters: @Model.characters.ToString("N0")<br />Words: @Model.words.ToString("N0")<br />Lines:
12+
@Model.lines.ToString("N0")
1213
</div>

text-counter-razor/wwwroot/css/site.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ body {
2626
}
2727

2828
#textOutput {
29-
white-space: pre-wrap;
29+
white-space: no-wrap;
3030
}

0 commit comments

Comments
 (0)