Skip to content

Commit

Permalink
Fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lulunac27a committed Nov 11, 2024
1 parent feaa8df commit dbe8dbc
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions text-counter-razor/Pages/TextCounter.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ public class TextCounterModel : PageModel

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
?.Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
.Length ?? 0;
Lines = TextContent?.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length ?? 0;
this.TextContent = this.Request.Form["textContent"]; //get text box input
this.Characters = this.TextContent?.Length ?? 0; //update number of characters, words and lines based on entered text
this.Words =
this.TextContent?.Split(
new char[] { ' ', '\r', '\n' },
StringSplitOptions.RemoveEmptyEntries
).Length ?? 0;
this.Lines =
this.TextContent?.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length ?? 0;
}
}

0 comments on commit dbe8dbc

Please sign in to comment.