Example input :
Hello World --> HelloWorld
Method
1: /// <summary>
2: /// Method to remove space in a string example : Hello world --> HelloWorld
3: /// </summary>
4: /// <param name="data"></param>
5: /// <returns></returns>
6: public static string removeSpace(string data)
7: {
8: Regex r = new Regex(@"\s+");
9: string _temp = "";
10: _temp = r.Replace(data, @"");
11: return _temp;
12: }
OR without static
1: /// <summary>
2: /// Method to remove space in a string example : Hello world --> HelloWorld
3: /// </summary>
4: /// <param name="data"></param>
5: /// <returns></returns>
6: public string removeSpace(string data)
7: {
8: Regex r = new Regex(@"\s+");
9: string _temp = "";
10: _temp = r.Replace(data, @"");
11: return _temp;
12: }
0 comments:
Post a Comment