Skip to content

Commit

Permalink
More string operations (#1091)
Browse files Browse the repository at this point in the history
* Add String.Insert and String.Remove

(cherry picked from commit 0b099ab)

* Stub string.Format

(cherry picked from commit 720da53)

* Add string.IsNullOrWhiteSpace(string)

(cherry picked from commit 36c956e)

---------

Co-authored-by: Phil Garcia <phil@thinkedge.com>
  • Loading branch information
jvyden and tgiphil committed Jul 27, 2023
1 parent e49409c commit 6a84b66
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Source/Mosa.Korlib/System/String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,21 @@ public string Replace(string s1, string s2)
return str;
}

public string Insert(int startIndex, string str)
{
return this.Substring(0, startIndex) + str + this.Substring(startIndex);
}

public string Remove(int startIndex, int count)
{
return this.Substring(0, startIndex) + this.Substring(startIndex + count);
}

public static string Format(string format, params object[] args)
{
return format;
}

public bool Equals(string s)
{
return Equals(this, s);
Expand Down Expand Up @@ -717,6 +732,19 @@ public static bool IsNullOrEmpty(string value)
return (value == null) || (value.Length == 0);
}

public static bool IsNullOrWhiteSpace(string value)
{
if (value == null) return true;

for (var i = 0; i < value.Length; i++)
{
if (!char.IsWhiteSpace(value[i]))
return false;
}

return true;
}

public bool Contains(string value)
{
return IndexOf(value) > -1;
Expand Down

0 comments on commit 6a84b66

Please sign in to comment.