How to remove the spaces in a given string?

Platform: ASP.NET|Category: Miscellaneous

Use the Namespace System.Text.RegularExpressions
VB.NET

Dim strval As String = 'Jack and Jill'
Dim strnewval As String = Regex.Replace(strval, ' ', '')
Response.Write(strnewval)

C#

string strval    = 'Jack and Jill';
string strnewval    = Regex.Replace(strval, ' ', '');
Response.Write(strnewval)	;