[chronojump/FS-TFT-Menu] Util.RemoveChar allows to remove totally or change by space (default)



commit 47c42fad61c5ca80102e80fa529e03311b1d192b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon May 2 10:57:32 2022 +0200

    Util.RemoveChar allows to remove totally or change by space (default)

 src/util.cs | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/util.cs b/src/util.cs
index 1657e3f60..2544dab51 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -449,13 +449,14 @@ public class Util
                return myStringBuilder.ToString();
        }
 
-       public static string RemoveNewLine(string myString, bool changeBySpace) 
+       public static string RemoveNewLine(string myString, bool changeBySpace)
        {
                StringBuilder myStringBuilder = new StringBuilder(myString);
                if(changeBySpace)
                        myStringBuilder.Replace("\n", " ");
                else
                        myStringBuilder.Replace("\n", "");
+
                return myStringBuilder.ToString();
        }
 
@@ -478,11 +479,20 @@ public class Util
                return s;
        }
 
-       //use this!!!   
-       public static string RemoveChar(string s, char c) 
+       //use on of this two methods
+       //this is the default, used by almost all methods: change to an space
+       public static string RemoveChar(string s, char c)
+       {
+               return RemoveChar(s, c, true);
+       }
+       public static string RemoveChar(string s, char c, bool changeBySpace)
        {
                StringBuilder myStringBuilder = new StringBuilder(s);
-               myStringBuilder.Replace(c,' ');
+               if(changeBySpace)
+                       myStringBuilder.Replace(c,' ');
+               else
+                       myStringBuilder.Replace(c.ToString(), "");
+
                return myStringBuilder.ToString();
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]