How to replace spaces with underscores in asp.net?

How can I replace a space in a string with an underscore in C#?

Type following code in code behind.


protected void Page_Load(object sender, EventArgs e)

{

string text= "Good Morning";

Response.Write(Replace(text));

}

static string Replace(string t)

{

return System.Text.RegularExpressions..Regex.Replace(t, @"\s+", "_");

}