Skip to content

Commit

Permalink
Add commas for thousand seperator for numeric output and make sure te…
Browse files Browse the repository at this point in the history
…xt counter output has no line wraps
  • Loading branch information
lulunac27a committed Feb 23, 2024
1 parent d0bd470 commit 0822213
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions text-counter-blazor/Components/Pages/TextCounter.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
{
textOutput = "";
string Value = textContent;
textOutput += $"Characters: {Value.Length}\n";//number of characters
textOutput += $"Words: {Value.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Length}\n";//number of words
textOutput += $"Lines: {Value.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length}\n";//number of lines
textOutput += $"Characters: {Value.Length.ToString("N0")}\n";//number of characters
textOutput += $"Words: {Value.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Length.ToString("N0")}\n";//number of words
textOutput += $"Lines: {Value.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length.ToString("N0")}\n";//number of lines
}
}
6 changes: 3 additions & 3 deletions text-counter-console-app/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
}
textContent += textInput + '\n';//add text content from entered text input for each line
}
Console.WriteLine($"Characters: {textContent.Length}");//number of characters
Console.WriteLine($"Words: {textContent.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Length}");//number of words
Console.WriteLine($"Lines: {textContent.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length}");//number of lines
Console.WriteLine($"Characters: {textContent.Length.ToString("N0")}");//number of characters
Console.WriteLine($"Words: {textContent.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Length.ToString("N0")}");//number of words
Console.WriteLine($"Lines: {textContent.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length.ToString("N0")}");//number of lines
3 changes: 2 additions & 1 deletion text-counter-razor/Pages/TextCounter.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<textarea id="textContent" name="textContent" rows="10" cols="80" asp-for="textContent"></textarea><br />
<button>Update Text Counter Output</button><br />
</form>
<div id="textOutput">Characters: @Model.characters<br />Words: @Model.words<br />Lines: @Model.lines
<div id="textOutput">Characters: @Model.characters.ToString("N0")<br />Words: @Model.words.ToString("N0")<br />Lines:
@Model.lines.ToString("N0")
</div>
2 changes: 1 addition & 1 deletion text-counter-razor/wwwroot/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ body {
}

#textOutput {
white-space: pre-wrap;
white-space: no-wrap;
}

0 comments on commit 0822213

Please sign in to comment.