Creating a reusable function lets you use it anywhere in your code project. I first created an identical function for ASP Classic and needed something similar in ASP.NET.
To use in your ASP.NET C# project, simply copy the above code and paste it into your project, replacing only the string characters you need to replace in your project.
public void Page_Load(object Sender, EventArgs e)
{
Response.Write(Encoding("Test (This is a test)"));
Response.Write(Decoding("Test {This is a test}"));
{
The above example will
Replace the Parentheses with {curly brackets} and add underscores where spaces are at.Output: Test_{This_is_a_test}
Replace the {curly brackets} with Parentheses and remove the underscores.Output: Test (This is a test);