From feaa8df0d15996c0c15fa2b07a11442c4d2eccee Mon Sep 17 00:00:00 2001 From: lulunac27a <100660343+lulunac27a@users.noreply.github.com> Date: Sun, 10 Nov 2024 18:51:40 -0600 Subject: [PATCH] Fix naming warnings --- text-counter-razor/Pages/TextCounter.cshtml | 6 +++--- text-counter-razor/Pages/TextCounter.cshtml.cs | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/text-counter-razor/Pages/TextCounter.cshtml b/text-counter-razor/Pages/TextCounter.cshtml index 10cb4b7..4e0e7a2 100644 --- a/text-counter-razor/Pages/TextCounter.cshtml +++ b/text-counter-razor/Pages/TextCounter.cshtml @@ -5,9 +5,9 @@ }

Text Counter in Razor Pages

-
+

-
Characters: @Model.characters.ToString("N0")
Words: @Model.words.ToString("N0")
Lines: - @Model.lines.ToString("N0") +
Characters: @Model.Characters.ToString("N0")
Words: @Model.Words.ToString("N0")
Lines: + @Model.Lines.ToString("N0")
diff --git a/text-counter-razor/Pages/TextCounter.cshtml.cs b/text-counter-razor/Pages/TextCounter.cshtml.cs index 480ca10..48ae262 100644 --- a/text-counter-razor/Pages/TextCounter.cshtml.cs +++ b/text-counter-razor/Pages/TextCounter.cshtml.cs @@ -4,19 +4,19 @@ public class TextCounterModel : PageModel { [BindProperty] - public string? textContent { get; set; } //text content string input from text box - public int characters { get; set; } //number of characters - public int words { get; set; } //number of words - public int lines { get; set; } //number of lines + public string? TextContent { get; set; } //text content string input from text box + public int Characters { get; set; } //number of characters + public int Words { get; set; } //number of words + public int Lines { get; set; } //number of lines public void OnPost() { - textContent = Request.Form["textContent"]; //get text box input - characters = textContent?.Length ?? 0; //update number of characters, words and lines based on entered text - words = - textContent + TextContent = Request.Form["textContent"]; //get text box input + Characters = TextContent?.Length ?? 0; //update number of characters, words and lines based on entered text + Words = + TextContent ?.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries) .Length ?? 0; - lines = textContent?.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length ?? 0; + Lines = TextContent?.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length ?? 0; } }