[chronojump] Util.RemoveChar allows to remove totally or change by space (default)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Util.RemoveChar allows to remove totally or change by space (default)
- Date: Mon, 2 May 2022 09:00:06 +0000 (UTC)
commit d19da5b3d88bea7159a9c5aa58433b8574339fe4
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]