-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7aba90
commit 7f78309
Showing
5 changed files
with
29 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
Console.WriteLine("Type text, then press Ctrl+D to calculate the number of characters, words and lines."); | ||
Console.WriteLine( | ||
"Type text, then press Ctrl+D to calculate the number of characters, words and lines." | ||
); | ||
string textContent = ""; | ||
while (true) | ||
{ | ||
string textInput = Console.ReadLine();//read text input in each line | ||
if (textInput == null | textInput == "")//if Ctrl+D is pressed or text input is empty | ||
string textInput = Console.ReadLine(); //read text input in each line | ||
if (textInput == null | textInput == "") //if Ctrl+D is pressed or text input is empty | ||
{ | ||
break;//end while loop | ||
break; //end while loop | ||
} | ||
textContent += textInput + '\n';//add text content from entered text input for each line | ||
textContent += textInput + '\n'; //add text content from entered text input for each line | ||
} | ||
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 | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,3 @@ public void OnGet() | |
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters