From a0fa3f38fff5a4a387ce2f47317da82008a09a9c Mon Sep 17 00:00:00 2001 From: Lukasz Baldyga Date: Sun, 29 Nov 2020 12:00:48 +0000 Subject: [PATCH] Updated Strip helper function I've discovered https://docs.microsoft.com/en-us/dotnet/api/system.string.trim?view=net-5.0 --- .../HelperFunctions.cs | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/Advanced Software Engineering/Advanced Software Engineering/HelperFunctions.cs b/Advanced Software Engineering/Advanced Software Engineering/HelperFunctions.cs index 98f0b31..22385b7 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/HelperFunctions.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/HelperFunctions.cs @@ -47,30 +47,7 @@ namespace Advanced_Software_Engineering { /// /// public static string Strip(string text) { - //Console.WriteLine("Stripping: '" + text + "'"); - int start; - - for (start = 0; start < text.Length; start++) { - char character = text[start]; - if (character != " "[0]) break; - } - - int end; - - for (end = text.Length - 1; end >= 0; end--) { - char character = text[end]; - if (character != " "[0]) break; - } - - if (end == -1) return ""; - - string result = text.Substring(start, end - start + 1); - - //Console.WriteLine("Started at: " + start); - //Console.WriteLine("Ended at: " + end); - //Console.WriteLine("Result: " + result); - - return result; + return text.Trim(); } ///