112
string test = "China lashes out at Hong Kong protest targeting its office Mon 22-Jul-19 10:33am";
1
using System;using System.Text; using System.Diagnostics; using System.Linq;
2
3
public static class Program
4
{
5
public static string RemoveWhiteSpace(this string s)
6
{
7
char[] r = new char[s.Length];
8
int idxr = 0;
9
for (int i = 0; i < s.Length; i++) {
10
if ( !Char.IsWhiteSpace(s[i])) {
11
r[idxr] = s[i];
12
idxr++;
13
}
14
}
15
return new string(r);
16
}
17
18
public static string StringBuilderRemoveWhiteSpace(this string s) {
19
20
StringBuilder sb = new StringBuilder();
21
for (int i = 0; i < s.Length; i++) {
22
if ( !Char.IsWhiteSpace(s[i])) {
23
sb.Append(s[i]);
24
}
Cached Result